fix: use wallet-substituted account in returned spend permission#349
Open
Snowmanzx wants to merge 1 commit into
Open
fix: use wallet-substituted account in returned spend permission#349Snowmanzx wants to merge 1 commit into
Snowmanzx wants to merge 1 commit into
Conversation
requestSpendPermission lets the wallet replace message.account via mutableData and computes permissionHash from the wallet-returned message, but built the returned permission object from the original pre-substitution typed data. When the wallet substituted the account, permission.account and permissionHash described different permissions. Carry the signed message through a variable and use it for both. Added a test that exercises the substitution.
Collaborator
🟡 Heimdall Review Status
|
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.
requestSpendPermission sends
mutableData: { fields: ['message.account'] }so the wallet may replace the account (for example swapping an EOA for a smart wallet). It computespermissionHashfrom the wallet-returnedsignedData.message, but built the returnedSpendPermission.permissionfrom the originaltypedData.message.When the wallet actually substitutes the account the two disagree:
permissionHashis over the new account whilepermission.accountstill holds the original. Anything downstream that readsresult.permission.account(display, storage, prepareSpendCallData, fetchPermissions) then sees the wrong address.Carry the signed message through a variable and use it for both the hash and the returned permission. The
eth_signTypedData_v4branch has no substitution so it is unchanged.Added a test where
signedData.message.accountdiffers from the request account and checks the returned permission matches the substituted message, not the original.Closes #324