Skip to content

feat(web3): extend AST-W02 with hardcoded fee-recipient detector#8

Merged
Markeljan merged 1 commit into
mainfrom
worktree-agent-a537591d63f169bee
May 7, 2026
Merged

feat(web3): extend AST-W02 with hardcoded fee-recipient detector#8
Markeljan merged 1 commit into
mainfrom
worktree-agent-a537591d63f169bee

Conversation

@Markeljan
Copy link
Copy Markdown
Collaborator

Summary

  • New W02-005 sub-rule detects address literals in fee/affiliate context within Permit2/swap typed-data, closing the 0x SKILL fee-skim pattern (hardcoded SWAP_FEE_RECIPIENT + SWAP_FEE_BPS baked into signed EIP-712 messages).
  • Heuristic: address literal that is NOT in manifest.web3.policy.allowedContracts AND appears within ~3 lines of a fee token (fee, feeBps, feeRecipient, swapFeeRecipient, swapFeeBps, affiliate, referrer, partner, takerFee, protocolFee, treasury).
  • Suppresses false positives for the zero address, the 0xdead burn sink, the canonical Permit2 verifyingContract, allowlisted contracts, comments, and lines with feeBps = 0 disclaimers.
  • Adds e2e fixture web3-feeskim-vuln-skill/ and 9 new unit tests.

Test plan

  • bun test --filter @agentsec/web3 — 253 pass, 0 fail
  • bun run build && bun run test — full monorepo, all green
  • bun 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

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>
@Markeljan Markeljan merged commit a9d4dc5 into main May 7, 2026
1 check passed
@Markeljan Markeljan deleted the worktree-agent-a537591d63f169bee branch May 7, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant