fix(scanner): skip STOR-004 on ERC-20 contract addresses#22
Merged
Conversation
The Header/Hero/Footer version chips were stamped into source by the bump script on every release. They now fetch from registry.npmjs.org/agentsec/latest via a new lib/version.ts helper using Next.js ISR (1h revalidate), with a fallback to packages/cli/package.json on failure. Page server components thread the resolved version to <Header>/<Hero>; Footer fetches directly. scripts/version-stamps.ts drops the three landing entries (7 stamps -> 4) and AGENTS.md is updated to reflect the new behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The STOR-004 "Hardcoded token detected" rule was matching any variable named `*token*` paired with a 16+ char value, which collides with the standard Web3 pattern of `fromToken="0x..."` / `toToken="0x..."` / `SELL_TOKEN="0x..."` carrying ERC-20 contract addresses. Those are public on-chain identifiers, not credentials. Add an exclusion: when the value is `"0x" + 40 hex chars` AND the identifier (before `=` or `:`) contains `token`, `addr`, `address`, or `contract`, skip the finding. Splitting on the assignment operator prevents a trailing comment from spoofing the hint check. JWT-style auth tokens (eyJ...) still trigger normally — covered by a regression test. Impact on `bun run compare:web3`: Odos goes from 51 D to 88 B, and all 11 router fixtures drop their false-positive "Hardcoded token detected" findings to zero. 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
The
storagerule's STOR-004 "Hardcoded token detected" pattern was matching any variable named*token*paired with a 16+ char quoted value. That collides with the standard Web3 pattern offromToken="0x..."/toToken="0x..."/SELL_TOKEN="0x..."carrying ERC-20 contract addresses — those are public on-chain identifiers, not credentials.What changed
isEvmAddressContext(content, index)and wired it into the scan loop alongside the existingisInComment/isExampleValueskips. Skip when the value is"0x" + 40 hex charsand the identifier portion (before=or:) containstoken,addr,address, orcontract. Splitting on the assignment operator means a trailing comment can't spoof the hint check.does not flag ERC-20 contract addresses as auth tokens— coversfromToken=,toToken=,SELL_TOKEN=,BUY_TOKEN=,tokenAddress:still flags JWT-style tokens even when var name contains 'token'— guards against over-broad exclusion (eyJ...JWT still detected)Impact
Re-running
bun run compare:web3:fromToken=/toToken=examples)storage.tsReviewer notes
"0x" + 40 hex(the EVM address shape) and an identifier hint. Auth tokens that happen to start with0xbut aren't 40-hex-char addresses still trigger.api_key,client_secret,password, AWS/GitHub/OpenAI/Slack value-pattern detectors) are unaffected — their identifier or value patterns don't collide with EVM addresses.e2e/web3.test.ts(WEB3_RULES registryrule-count expectations) are present on the clean tree and unrelated to this change.Test plan
bun test packages/scanner/src/__tests__/storage.test.ts— 60 pass, including 2 newbun run compare:web3— Odos 88 B, zeroHardcoded token detectedacross all 11 routers🤖 Generated with Claude Code