Skip to content

fix(zerox): exact Permit2 allowance and EIP-712 bind checks - #1394

Open
SashaMIT wants to merge 1 commit into
coinbase:mainfrom
SashaMIT:fix/zerox-exact-permit2-allowance-and-eip712-bind
Open

fix(zerox): exact Permit2 allowance and EIP-712 bind checks#1394
SashaMIT wants to merge 1 commit into
coinbase:mainfrom
SashaMIT:fix/zerox-exact-permit2-allowance-and-eip712-bind

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 4, 2026

Copy link
Copy Markdown

Description

execute_swap_on_0x previously:

  1. Approved Permit2 with maxUint256 whenever the price response reported an allowance issue
  2. Blind-signed quote.permit2.eip712 with no local binding checks

That combination means a compromised or MITM’d 0x response path can inherit an unlimited allowance and obtain signatures over attacker-controlled typed data.

This change:

  • Approves only the swap’s sellAmount (not unlimited)
  • Validates Permit2 EIP-712 verifyingContract, chainId, token, and amount against local swap intent before signTypedData
  • Adds unit tests for mismatch rejection

AI disclosure

Drafted with AI assistance; reviewed against the Permit2 / blind EIP-712 agent-wallet risk class.

Test plan

  • Unit tests for bind helper
  • Existing zeroX action tests still pass (mocks)
  • CI on this PR

@SashaMIT
SashaMIT requested a review from murrlincoln as a code owner August 4, 2026 09:39
@cb-heimdall

cb-heimdall commented Aug 4, 2026

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions Bot added action provider New action provider typescript labels Aug 4, 2026
Stop granting maxUint256 to Permit2 and reject quote typed-data that does
not match the local sell token, amount, chain, and Permit2 verifyingContract.
@SashaMIT
SashaMIT force-pushed the fix/zerox-exact-permit2-allowance-and-eip712-bind branch from bc25485 to a72aebc Compare August 4, 2026 14:39
@SashaMIT

SashaMIT commented Aug 5, 2026

Copy link
Copy Markdown
Author

Friendly bump — these three tips harden agent spend paths (allowlist matching, Jupiter slippage cap, Permit2 amount + EIP-712 bind). Happy to adjust naming/tests if anything conflicts with your roadmap. Tips are SSH-signed under SashaMIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants