feat(signature-controller): allow EIP-7702 self-signatures where verifyingContract equals signer#7836
Open
zerodustxyz wants to merge 1 commit intoMetaMask:mainfrom
Conversation
…fyingContract equals signer With EIP-7702, EOAs can temporarily delegate to smart contracts, making the user's address itself become a contract. Protocols using EIP-7702 (like account abstraction and sponsored transactions) need to sign EIP-712 messages where the verifyingContract is the user's own address. This change adds an exception to the verifying contract validation: when the signer's address matches the verifyingContract, the signature is allowed. This is safe because: 1. The user is signing for their own address (not someone else's) 2. EIP-7702 delegation is a legitimate use case enabled by Pectra 3. The existing check still blocks external requests from using OTHER internal accounts as verifyingContract Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
This PR adds an exception to the
validateVerifyingContractfunction in the signature-controller to support EIP-7702 delegated accounts, enabling MetaMask users to interact with next-generation protocols that leverage temporary smart contract delegation.The Problem: Dust Across Many Chains
Users accumulate small native token balances ("dust") across dozens of chains that are too small to bridge or swap due to gas costs. Until now, there was no way to sweep these balances to exactly zero.
With EIP-7702 (EIP-7702: Set EOA account code), protocols can now offer sponsored transactions where a third party pays gas on behalf of the user. However, when signing EIP-712 typed data in this context, the
verifyingContractin the domain is legitimately the user's own address (because their EOA is temporarily acting as a contract).Currently, MetaMask blocks these signatures with the error:
This security check is important for preventing phishing attacks, but it incorrectly blocks legitimate EIP-7702 use cases.
The Solution
Add an exception when the
verifyingContractequals thesignerAddress(thefromfield in the message params). This is a safe exception because:User Flow with This Fix
First Approval - EIP-712 Sweep Intent
The user signs a typed data message specifying the sweep parameters. Note how the
verifyingContractis the user's own address:Second Approval - Transaction Confirmation
Standard transaction confirmation for executing the sweep:
Changes
signerAddressparameter tovalidateVerifyingContractfunctionverifyingContract === signerAddress(case-insensitive)Testing
Added two test cases:
Related