-
Notifications
You must be signed in to change notification settings - Fork 921
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
Reject Solana SignTransaction/SignAllTransactions when blockhash is invalid #18200
Conversation
e35f306
to
c154ac6
Compare
@@ -305,6 +292,13 @@ bool WaitForWalletBubble(content::WebContents* web_contents) { | |||
|
|||
return tab_helper->IsShowingBubble(); | |||
} | |||
|
|||
void CloseWalletBubble(content::WebContents* web_contents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add it to multiple Call* functions otherwise WaitForWalletBubble
isn't working as what we expected because it was never dismissed after the previous request (we use NotifyXXXProcessed directly so UI doesn't really get dismissed).
params.Append(blockhash); | ||
|
||
base::Value::Dict configuration; | ||
configuration.Set("commitment", commitment ? *commitment : "processed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use processed
as default so newer blockhash won't be invalid.
d3f45e4
to
218e798
Compare
7c910fd
to
21bcc78
Compare
@@ -9,6 +9,7 @@ | |||
<message name="IDS_WALLET_EXPECTED_SINGLE_PARAMETER" desc="The text of the response for wallet_addEthereumChain call with empty parameters">Expected single, object parameter.</message> | |||
<message name="IDS_WALLET_CHAIN_EXISTS" desc="The text of the response for wallet_addEthereumChain call with existing chain id">This Chain ID is currently used</message> | |||
<message name="IDS_WALLET_INTERNAL_ERROR" desc="The text of the response for wallet_addEthereumChain call with internal error">An internal error has occurred</message> | |||
<message name="IDS_WALLET_INVALID_BLOCKHASH_ERROR" desc="The text of the response for Solana signTransaction and signAllTransactions with invalid blockhash or unable to validate due to network or RPC error">Blockhash is invalid or unable to be validated</message> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Blockhash is invalid or can not be validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings ++ (with a suggestion)
21bcc78
to
bf6ffdf
Compare
macOS had a known test failure: |
Screen.Recording.2023-04-24.at.1.06.07.PM.mov@yrliou from what I'm seeing locally, this is breaking proper transaction signing now. Is this what you saw when you tested the happy path case as well? |
@kdenhartog I didn't use their dApp to test the happy path but used our own dApp's normal cases which works fine, can test theirs tomorrow. |
@kdenhartog I just tested it locally on master, signing works on mainnet and failed due to blockhash invalid error on devnet. |
Ok must just be a local failure for me - thanks for double checking. I just tested on the PR build rather than master so that's probably the issue for me. I'll go ahead and close out the H1 issue - thanks for fixing so quickly! |
@kdenhartog PR build should work too, not sure if it's environment or the some mistakes during testing, feel free to reach out to me if it's broken for you on latest nightly. |
…nvalid (#18200) * Add Solana IsBlockhashValid JSON-RPC support * Reject Solana SignTransaction/SignAllTransactions when blockhash is invalid
Verification passed on
Verification passed on
Verified 18200-Sign.Transactions.mp4 |
Resolves brave/brave-browser#29798
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Sign Transaction (Invalid blockhash)
, wallet panel won't prompt and should see[error] signTransactionWithInvalidBlockhash: {"code":-32603,"message":"Blockhash is invalid or can not be validated"}
on the screen.Sign All Transactions (Invalid blockhash)
, wallet panel won't prompt and should see[error] signAllTransactionsWithInvalidBlockhash: {"code":-32603,"message":"Blockhash is invalid or can not be validated"}
on the screen.Sign Transaction
andSign All Transactions (multiple)
. In both cases, transaction signing prompt should be shown, and shouldn't see blockhash is invalid error. Note: It could fail after you approve for other reasons like insufficient funds or no record of a prior credit, which is fine.There is also a test case provided in the hackerone report, but requires manual setup, please reach out to me for the zip of the repo and how to configure it.
(I did verify it locally, however, I think the tests I added in our test dApp should be enough. So maybe just test below on one platform to be extra safe.)
For testing the dApp in the hackerone report:
yarn setup
in that repo folder. (Node v18 is needed.)solana-cross-cluster-poc/src/cross-cluster.js
, replace the address inaccounts
with address of your Solana Account 1 (around line 9), and replace address used asattackerPubkey
with address of your Solana Account 2 (around line 77).yarn start
under the repo folder.Default Solana Wallet
setting is set toBrave Wallet
and set active Solana network to mainnet beta.SEND FUNDS…
, should see prompt for transaction signing. Approve it. Depends on whether you have funds available in your account, you’ll either see error later due to insufficient fund when the dApp trying to send transaction, or you'll see it successfully sends out a transaction and gives you the tx hash that you can query on explorer if you have funds enough to complete the transaction.SEND FUNDS…
, wait for error{"code":-32603,"message":"Blockhash is invalid or can not be validated"}
to show up and you should not see any prompt for transaction signing.