Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap window.ethereum._metamask in gin::Wrappable #18411

Merged
merged 1 commit into from
May 9, 2023

Conversation

darkdh
Copy link
Member

@darkdh darkdh commented May 8, 2023

so that _metamask and ethereum have equivalent lifetime.

Resolves brave/brave-browser#30204

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Described in the issue

so that _metamask and ethereum have equivalent lifetime.
@darkdh darkdh requested a review from bbondy May 8, 2023 23:43
@darkdh darkdh requested a review from a team as a code owner May 8, 2023 23:43
@darkdh darkdh self-assigned this May 8, 2023
v8::Global<v8::Promise::Resolver>(isolate, resolver.ToLocalChecked()));
auto context(v8::Global<v8::Context>(isolate, isolate->GetCurrentContext()));
ethereum_provider_->IsLocked(base::BindOnce(
&JSEthereumProvider::MetaMask::OnIsUnlocked, base::Unretained(this),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with owning mojo::Remote, we don't need weak_ptr because the previous bound callback won't be called when mojo disconnected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to avoid using base::Unretained(this) here? It seems like this opens up the possibility of another issue occurring if this object is destroyed before the async operation is completed based on what's being described here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional, when dealing with mojo interface, using weak_ptr is unnecessary. Mojo pipe will invalidate all of the ongoing message when disconnected so OnIsUnlocked won't be called when the class who owns mojo::Remote<mojom::EthereumProvider> is gone.

Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@darkdh darkdh enabled auto-merge May 9, 2023 05:39
@kjozwiak kjozwiak self-requested a review May 9, 2023 07:25
Copy link
Member

@kjozwiak kjozwiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the needed ++, going to merge so we can uplift into 1.51.x and get RC builds running for tomorrow.

@kjozwiak kjozwiak disabled auto-merge May 9, 2023 07:25
@kjozwiak kjozwiak merged commit a8e497b into master May 9, 2023
@kjozwiak kjozwiak deleted the eth-provider-binding branch May 9, 2023 07:25
@github-actions github-actions bot added this to the 1.53.x - Nightly milestone May 9, 2023
kjozwiak pushed a commit that referenced this pull request May 9, 2023
kjozwiak pushed a commit that referenced this pull request May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hackerone] wallet ethereum provider binding security issue
3 participants