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

Fixing nullptr dereference in RewardsDOMHandler. #9622

Conversation

szilardszaloki
Copy link
Collaborator

@szilardszaloki szilardszaloki commented Aug 3, 2021

Resolves brave/brave-browser#17259.

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
  • 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, npm run lint, 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:

See Steps to Reproduce here.

@szilardszaloki szilardszaloki requested a review from a team as a code owner August 3, 2021 11:02
@szilardszaloki szilardszaloki self-assigned this Aug 3, 2021
@szilardszaloki szilardszaloki changed the title Fixing nullptr dereference in RewardsDOMHandler. Fixing nullptr dereference in RewardsDOMHandler. Aug 3, 2021
@szilardszaloki szilardszaloki changed the title Fixing nullptr dereference in RewardsDOMHandler. Fixing nullptr dereference in RewardsDOMHandler. Aug 3, 2021
ledger::type::ExternalWalletPtr wallet) {
if (IsJavascriptAllowed()) {
CallJavascriptFunction("brave_rewards.externalWalletLogin",
base::Value(wallet->login_url));
base::Value(wallet ? wallet->login_url : ""));
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we can drop the Result param completely if we're not using it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's required by GetExternalWalletCallback.

@szilardszaloki szilardszaloki merged commit 1a1278e into master Aug 4, 2021
@szilardszaloki szilardszaloki deleted the sszaloki-17259-fixing-nullptr-dereference-in-RewardsDOMHandler branch August 4, 2021 22:45
@LaurenWags
Copy link
Member

LaurenWags commented Aug 6, 2021

Verification in progress with

Brave | 1.30.5 Chromium: 92.0.4515.131 (Official Build) nightly (x86_64)
-- | --
Revision | 6b8d6c56ce21e38a72f7c4becb5abc1fa5134f29-refs/branch-heads/4515@{#1933}
OS | macOS Version 10.15.7 (Build 19H1323)

Verified STR from

  1. Using current release version, 1.27.111, clean profile, staging env, enable Rewards, link KYC'd Uphold wallet
  2. Manually disconnect from Uphold (from wallet panel)
  3. Confirm you are returned to pre-link state (UI, no balance, etc)
  4. Link a second (different) KYC'd Uphold wallet
  5. Confirm UI appears fine (UI, balance is shown), but logs show 403 error for linking

example logs:

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9..........2/claim
> Method: POST
> Content: {"signedLinkingRequest":"eyJ..........
> Content Type: application/json; charset=utf-8
[6026:775:0806/120953.585781:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9............2/claim
> Result: Failure
> HTTP Code: 403
> Body: {"message":"error linking wallet: unable to link wallets: unable to match wallets: wallets do not match","code":403}
[6026:775:0806/120953.585888:VERBOSE9:logging_util.cc(137)] 
[ RESPONSE HEADERS ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9.............2/claim
[6026:775:0806/120953.587074:INFO:post_claim_uphold.cc(112)] Forbidden
[6026:775:0806/120953.587962:INFO:wallet.cc(169)] Claiming anon funds failed
  1. Close browser
  2. "Upgrade" (rename profile to Brave-Browser-Nightly) to 1.30.x
  3. Open panel and confirm your 2nd verified, KYC'd wallet from step 4 is no longer connected (you do not see "Wallet Verified" or balance)
  4. You still see 403 error in logs.

example logs:

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9............2/claim
> Method: POST
> Content: {"signedLinkingRequest":"eyJ.............
> Content Type: application/json; charset=utf-8
[6138:775:0806/121334.260065:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9...............2/claim
> Result: Failure
> HTTP Code: 403
> Body: {"message":"error linking wallet: unable to link wallets: unable to match wallets: wallets do not match","code":403}
[6138:775:0806/121334.260170:VERBOSE9:logging_util.cc(137)] 
[ RESPONSE HEADERS ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/9...........2/claim
[6138:775:0806/121334.261330:INFO:post_claim_uphold.cc(123)] Forbidden
  1. From panel, click on "Verify wallet"
    --> You are in PENDING state
Example Example
Screen Shot 2021-08-06 at 12 24 45 PM Screen Shot 2021-08-06 at 12 25 46 PM

Since you are now in PENDING (Fixed with brave/brave-browser#17316), you can't get to the UI that caused the crash. Additionally, once brave/brave-browser#17271 is merged, you will get a notification about this particular scenario.

Once brave/brave-browser#17265 is fixed, you will be able to get to the UI that caused the crash in a close approximation of this scenario.

Since I can't quite check that the crash doesn't occur in this scenario at present, I took these additional steps:

  • manually Disconnected from Uphold

Screen Shot 2021-08-06 at 12 29 24 PM

  • Clicked on Verify wallet --> Selected Continue on the modal --> Selected Uphold option --> selected Continue to login
  • Confirmed no crash at this point

Confirming the above with @szilardszaloki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crash when trying to re-link previous Uphold account in certain case
4 participants