token-approval-safety
Skill8 starsChanged 9 months agoMITView on GitHub
Guide to ERC-20 token approvals — how they work, why unlimited approvals are risky, how to check and revoke approvals, and best practices. Use when helping users manage approvals, audit wallet security, or understand approval-related risks.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- sperax-skillsSkill
- agent-wallet-securitySkill
- ai-agent-defi-guideSkill
- airdrop-hunting-guideSkill
- arbitrum-defi-guideSkill
- chainlink-oracle-guideSkill
- cross-chain-bridge-guideSkill
- crypto-governance-guideSkill
- crypto-market-sentimentSkill
- crypto-news-aggregationSkill
- crypto-portfolio-managementSkill
- crypto-price-data-guideSkill
- crypto-tax-basicsSkill
- dca-strategy-guideSkill
- defi-dashboard-buildingSkill
- defi-lending-guideSkill
- defillama-analytics-guideSkill
- defi-risk-assessmentSkill
- defi-yield-strategiesSkill
- erc8004-agent-identitySkill
- gas-optimization-guideSkill
- impermanent-loss-explainedSkill
- mev-protection-guideSkill
- nft-analytics-guideSkill
- onchain-analytics-guideSkill
- plutus-plsassets-guideSkill
- plutus-protocol-overviewSkill
- plutus-vaults-guideSkill
- restaking-explainedSkill
- smart-contract-reading-guideSkill
- sperax-ecosystem-overviewSkill
- sperax-farms-guideSkill
- sperax-spa-stakingSkill
- sperax-usds-guideSkill
- stablecoin-mechanicsSkill
- subgraph-development-guideSkill
- token-discovery-guideSkill
- token-swap-best-practicesSkill
- web3-glossarySkill
- whale-watching-guideSkill
- yield-vault-guideSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 13 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When you interact with a DeFi protocol, you must first "approve" it to spend your tokens:
- Distinctive: line 26
If the protocol gets hacked, attackers drain your tokens via the approval
- Distinctive: line 69
After you're done using a protocol
- Distinctive: line 70
If a protocol announces a security incident
- Distinctive: line 72
Before a token migration or contract upgrade
- Distinctive: line 83
Prevention: Always verify the contract address before approving
- Distinctive: line 87
If a protocol with your approval gets hacked:
- Distinctive: line 91
Prevention: Use exact-amount approvals, revoke unused approvals
- Distinctive: line 99
No on-chain transaction to alert you
- Distinctive: line 101
Prevention: Read what you're signing carefully, use wallets that show permit details
- Distinctive: line 107
Use exact-amount approvals: when possible
- Distinctive: line 116
Batch revocations: when gas is low
- Distinctive: line 131
When helping users with approvals:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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
Token Approval Safety Guide
Token approvals are one of the most overlooked security risks in DeFi. This guide helps AI agents protect users from approval-related attacks.
How Approvals Work
When you interact with a DeFi protocol, you must first "approve" it to spend your tokens:
1. You call approve(spenderAddress, amount) on the token contract
2. The spender (DEX, protocol) can now transfer up to `amount` of your tokens
3. When you swap/deposit, the protocol calls transferFrom() to move your tokensThe Problem: Unlimited Approvals
Most DeFi UIs request unlimited approval (type(uint256).max):
- Saves gas on future interactions (no re-approval needed)
- But: the protocol can spend ALL your tokens FOREVER
- If the protocol gets hacked, attackers drain your tokens via the approval
Risk Levels
| Approval Type | Risk | When to Use |
| Exact amount | Low | Large deposits, untrusted protocols |
| Limited amount | Medium | Regular use with trusted protocols |
| Unlimited | High | Only with battle-tested protocols (Uniswap, Aave) |
| Permit (EIP-2612) | Medium | Gasless approvals, common in modern DeFi |
How to Check Approvals
On-Chain (Direct)
Query the token contract: allowance(ownerAddress, spenderAddress)
Tools
| Tool | URL | Features |
| Revoke.cash | https://revoke.cash | Most popular, multi-chain |
| Etherscan Token Approvals | https://etherscan.io/tokenapprovalchecker | Ethereum-only |
| Arbiscan | https://arbiscan.io/tokenapprovalchecker | Arbitrum |
What to Look For
- Unlimited approvals to contracts you no longer use
- Approvals to unknown contracts you don't recognize
- Old approvals from months/years ago
- Approvals for valuable tokens (USDC, USDT, WETH)
Revoking Approvals
Revoking sets the allowance to 0:
approve(spenderAddress, 0)Cost: Small gas fee per revocation
When to revoke:
- After you're done using a protocol
- If a protocol announces a security incident
- During regular security checkups (monthly recommended)
- Before a token migration or contract upgrade
Common Attack Vectors
1. Approval Phishing
Attacker tricks you into approving a malicious contract:
- Fake DEX frontends
- Phishing links disguised as protocol UIs
- "Claim airdrop" scam sites
Prevention: Always verify the contract address before approving
2. Compromised Protocol
If a protocol with your approval gets hacked:
- Attacker can drain your approved tokens immediately
- They don't need your private key — just the approval
Prevention: Use exact-amount approvals, revoke unused approvals
3. Permit Signature Phishing
EIP-2612 permits are signed off-chain (no gas). Attackers can trick you into signing a permit that grants them unlimited approval:
- Looks like a harmless "sign this message" request
- Actually authorizes token spending
- No on-chain transaction to alert you
Prevention: Read what you're signing carefully, use wallets that show permit details
Best Practices
For Regular Users
- Use exact-amount approvals when possible
- Review approvals monthly using Revoke.cash
- Revoke approvals to protocols you no longer use
- Use a dedicated DeFi wallet — don't hold all tokens where you approve
- Read approval prompts — check the spender address matches the expected protocol
For Frequent DeFi Users
- Separate hot/cold wallets — cold wallet for storage, hot wallet for DeFi
- Batch revocations when gas is low
- Prefer EIP-2612 permits for modern protocols (single-use)
- Set up alerts for large approval events on your address
- Audit before depositing large amounts — check existing approvals first
Approval Hygiene Checklist
- Check all active approvals at least monthly
- Revoke any approvals to contracts you don't recognize
- Revoke approvals to protocols you've stopped using
- Use exact amounts for new approvals when available
- Verify contract addresses on block explorers before approving
Agent Tips
When helping users with approvals:
- Always warn about unlimited approvals — suggest exact-amount when possible
- Before any large DeFi interaction — suggest checking existing approvals
- After security incidents — immediately recommend revoking approvals to affected protocol
- New users — explain approvals before their first DeFi transaction
- Gas consideration — revocations cost gas, batch them when gas is low
Links
- Revoke.cash: https://revoke.cash
- Etherscan Approval Checker: https://etherscan.io/tokenapprovalchecker
- Sperax (secure DeFi on Arbitrum): https://app.sperax.io
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.

