approval-issues
Skill36 starsChanged 5 months agoMITView on GitHub
Detect ERC-20 approval pitfalls — approve race (front-run), missing safeApprove, infinite approvals, approval-without-revoke, Permit2 misuse, max-approval to untrusted contracts. Activate on `approve`, `safeApprove`, `permit`, `forceApprove`, `Permit2`, `IERC20.allowance`.
In this repository44 other files it gives its agents.
- access-controlSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Use forceApprove(spender, Y) (OZ ≥4.9), or decreaseAllowance / increaseAllowance, or zero-first.
- Very specific: line 75
Always use OZ forceApprove for setting.
- Very specific: line 76
After a router/exec call: safeApprove(target, 0) to reset.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Approval issues detection
When this applies
- Any
approve/safeApprove/forceApprovesite permit(EIP-2612, DAI-style, Permit2)- Routers / aggregators that hold persistent approvals
- Vaults that approve strategies to pull funds
- Bridges / cross-chain approvers
Detection patterns
The classic ERC-20 approve race (HIGH)
token.approve(spender, X); // later
token.approve(spender, Y); // ← spender can front-run and drain X+YUse forceApprove(spender, Y) (OZ ≥4.9), or decreaseAllowance / increaseAllowance, or zero-first.
approve instead of safeApprove on non-standard tokens (HIGH)
USDT requires approve-to-zero before approve-to-X. Use OZ forceApprove.
Infinite approval to mutable contract (HIGH)
token.approve(router, type(uint256).max); // ← router is upgradeable, future impl can drainMitigate with allowance-per-action.
Per-pull infinite approval (HIGH)
Vault → strategy infinite approval; if strategy is upgradeable or has a bug, vault funds drainable.
Permit2 sig stolen / replayed (HIGH)
Permit2 signatures are bearer instruments — anyone with the sig can transfer. If the signed payload is logged or leaked, funds are drainable until the nonce is invalidated. Add a deadline.
permit then ignore failure (MEDIUM)
try IERC20Permit(token).permit(owner, spender, ...) {} catch {}
token.transferFrom(owner, ...); // ← if permit fails, uses any stale allowanceCaller can grief by front-running permit. Acceptable IFF you then check the allowance is sufficient.
Approval to address(0) on revoke (LOW)
Some tokens treat approve(0, x) as a no-op or revert. Use the documented revoke method.
Allowance still set after action completes (HIGH for routers)
token.safeApprove(target, amount);
target.swap(...);
// ← allowance lingers; if `amount` was max, target keeps powerSet to 0 after each action, or use a single-tx wrapper.
Approve to factory / clone-deployer (HIGH)
Deployer can deploy attacker-controlled implementation that consumes the approval.
Severity rubric
| Pattern | Severity |
| Persistent infinite approval to upgradeable router | High |
Approve race ignored, no forceApprove / increaseAllowance | High |
| USDT-style approve without zero-reset | High |
| Vault → strategy infinite allowance with mutable strategy | High |
| Permit2 with no deadline | High |
| Permit failure swallowed, allowance not re-checked | Medium |
| Lingering allowance after one-shot router action | High |
Remediation patterns
- Always use OZ
forceApprovefor setting;safeIncreaseAllowancefor top-ups. - After a router/exec call:
safeApprove(target, 0)to reset. - For vault→strategy: pull-only allowances and per-cycle resets.
- Permit2: short deadlines (minutes), per-payload nonce, bind to specific recipient + amount.
- For EOA users: surface the actual amount in the UI; never auto-approve max from the contract.
False-positive notes
- Internal-only approve where source and spender are both controlled → Info.
- WETH9-style
approvereturning bool always-true is well-known and safe.
Related
- [[token-compatibility]]
- [[signature-replay]] — Permit2 / EIP-2612
- [[mev-frontrunning]] — approve race is an MEV pattern
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

