fix: show filled PSBT in signPsbt confirmation#606
Open
jeremytsng wants to merge 3 commits into
Open
Conversation
The signPsbt confirmation showed the unfilled template PSBT supplied by the dApp, while a freshly filled PSBT (with the dApp's feeRate) was the one actually signed. The user could not see the inputs, real fee, or feeRate before approving, allowing a malicious dApp to spoof the displayed transaction. Fill the PSBT before showing the confirmation when options.fill is true, and pass fill=false to the inner signPsbt so the use case does not double-fill (which would re-introduce divergence between displayed and signed transaction).
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Contributor
|
Please, consider:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
The signPsbt confirmation showed the unfilled template PSBT supplied by the dApp, while a freshly filled PSBT (with the dApp's feeRate) was the one actually signed. The user could not see the inputs, real fee, or feeRate before approving, allowing a malicious dApp to spoof the displayed transaction.
Fill the PSBT before showing the confirmation when options.fill is true, and pass fill=false to the inner signPsbt so the use case does not double-fill (which would re-introduce divergence between displayed and signed transaction).
Screenshots
References
Checklist
Note
Medium Risk
Touches PSBT signing flow and confirmation data, so a mistake could cause users to approve/sign a different transaction than displayed. Changes are localized and covered by new unit tests for fill ordering and failure behavior.
Overview
Fixes
KeyringRequestHandler#signPsbtso whenoptions.fillis true it fills the PSBT before displaying the confirmation, ensuring the user reviews the same transaction that will be signed.The handler now signs the filled PSBT while forcing
{ fill: false }for the innersignPsbtcall to avoid double-filling and reintroducing divergence; tests were updated/added to assert call order, parsing behavior, and that failures infillPsbtabort confirmation and signing. Changelog updated to note the fix.Reviewed by Cursor Bugbot for commit 99d72ae. Bugbot is set up for automated code reviews on this repo. Configure here.