feat(web3): extend AST-W02 with hardcoded fee-recipient detector#8
Merged
Conversation
Detects address literals that sit inside a fee/affiliate context within Permit2 typed-data assembly and aren't declared in web3.policy.allowedContracts. Closes the 0x SKILL fee-skim pattern (hardcoded SWAP_FEE_RECIPIENT + SWAP_FEE_BPS baked into the signed EIP-712 message) that the existing W02 sub-rules don't catch. Co-Authored-By: Claude Opus 4.7 (1M context) <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
SWAP_FEE_RECIPIENT+SWAP_FEE_BPSbaked into signed EIP-712 messages).manifest.web3.policy.allowedContractsAND appears within ~3 lines of a fee token (fee,feeBps,feeRecipient,swapFeeRecipient,swapFeeBps,affiliate,referrer,partner,takerFee,protocolFee,treasury).0xdeadburn sink, the canonical Permit2 verifyingContract, allowlisted contracts, comments, and lines withfeeBps = 0disclaimers.web3-feeskim-vuln-skill/and 9 new unit tests.Test plan
bun test --filter @agentsec/web3— 253 pass, 0 failbun run build && bun run test— full monorepo, all greenbun packages/cli/src/cli.ts audit --path e2e/fixtures/web3-feeskim-vuln-skill --verbose— fires AST-W02 critical "Hardcoded fee recipient in Permit2/swap typed-data"bun packages/cli/src/cli.ts audit --path e2e/fixtures/good-web3-skill --verbose— no new findings (regression clean)bun packages/cli/src/cli.ts audit --path e2e/fixtures/w02-permit2-vuln-skill --verbose— existing W02-001/002/003/010 still flag🤖 Generated with Claude Code