Skip to content

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

Closed
SashaMIT wants to merge 2 commits into
coinbase:mainfrom
SashaMIT:fix/zerox-exact-permit2-allowance-and-eip712-bind
Closed

fix(zerox): exact Permit2 allowance and EIP-712 bind checks#1394
SashaMIT wants to merge 2 commits 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

Follow-up tighten (2026-08-05)

  • Require domain.chainId; reject wrong/missing domain.name when present
  • Exact Permit2 amount match (not ≥)
  • Bind message.spender to quote.transaction.to when to is present
  • Reject expired deadline
  • Expanded unit tests in utils.permit2Bind.test.ts

@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 1
Sum 2

@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.

Require domain.chainId, exact sell amount, optional spender==tx.to,
and non-expired deadline before signTypedData.

Co-authored-by: Cursor <cursoragent@cursor.com>
@SashaMIT

Copy link
Copy Markdown
Author

Consolidating our open queue to reduce triage load. Closing this for now; the core set we are keeping open is #1392, #1404, #1405, #1409, #1421, #1423. Happy to reopen or refile this specific fix if a maintainer wants it.

@SashaMIT SashaMIT closed this Aug 10, 2026
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