fix(enforcers): reject non-zero native value on ERC20 streaming and ownership transfer - #197
Open
SashaMIT wants to merge 1 commit into
Open
fix(enforcers): reject non-zero native value on ERC20 streaming and ownership transfer#197SashaMIT wants to merge 1 commit into
SashaMIT wants to merge 1 commit into
Conversation
…wnership transfer ERC20StreamingEnforcer and OwnershipTransferEnforcer decoded executions as (target,, callData) and never constrained native value. Token/ownership-scoped delegations could therefore accompany unbounded ETH on payable transfer / transferOwnership targets. Match ApprovalRevocationEnforcer / MultiTokenPeriodEnforcer (and open MetaMask#195 siblings) by requiring value == 0. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.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
Sibling of #195. Two more enforcers still decoded executions as
(target,, callData)and never constrained native ETH:ERC20StreamingEnforcer(streaming ERC20transfer)OwnershipTransferEnforcer(transferOwnership)The framework executes
target.call{value: value}(callData)from the delegator's account, so a token/ownership-scoped delegation placed no constraint on ETH riding along. For standard non-payable selectors this is inert today, but any payabletransfer/transferOwnershiptarget turns the delegation into an unbounded native spend.The repo already requires
value == 0inApprovalRevocationEnforcerandMultiTokenPeriodEnforcer(ERC20 path), and #195 covers the other transfer enforcers. This PR brings the two remaining outliers into that pattern.Fix
Bind
value_fromdecodeSingleandrequire(value_ == 0, "...:invalid-value")before the existing length/method checks.Test plan
test_revertOnNonZeroValueon both suites (executionvalue = 1expectsinvalid-value)requiremakestest_revertOnNonZeroValuefail (next call did not revert as expected); restore passesforge test --match-contract 'ERC20StreamingEnforcerTest|OwnershipTransferEnforcerTest'— 30/30 passMade with Cursor