Back to Security & Vulnerability Analysis

token-integration-analyzer

web3blockchainsmart contractsERC20ERC721security audittokenomicsdefi
⭐ 5.7kπŸ“„ CC-BY-SA-4.0πŸ•’ 2026-06-15Source β†—

Install this skill

npx skills add trailofbits/skills

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

The token-integration-analyzer provides a specialized diagnostic framework for evaluating security risks within Solidity smart contracts interacting with ERC20 and ERC721 assets. It systematically cross-references code against the Trail of Bits weird ERC20 database to identify implementation flaws that standard auditors often miss. The agent performs static analysis using Slither, verifies compliance with token standards, and audits protocol logic for external dependencies like fee-on-transfer mechanics, reentrancy vulnerabilities, or non-standard return values. By scrutinizing owner privileges and centralisation risks, it helps developers harden their systems against edge cases frequently exploited in DeFi protocols. This tool is specific to EVM-based architectures and provides actionable intelligence on token scarcity, holder distribution, and integration safety patterns essential for preparing contracts for mainnet deployment.

When to Use This Skill

  • β€’Auditing a DeFi protocol that interacts with arbitrary third-party tokens
  • β€’Verifying that a custom token implementation handles edge cases like low/high decimals
  • β€’Checking integration safety for tokens with fee-on-transfer behavior
  • β€’Assessing centralized risks in a new DAO or token deployment

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • β€œRun a token integration analysis on my contract
  • β€œCheck my ERC20 token for weird implementation patterns
  • β€œAssess the security of my protocol's token handling logic
  • β€œIs my token implementation compliant with industry standards?
  • β€œIdentify risks in my contract's interaction with external tokens

Pro Tips

  • πŸ’‘For the most accurate analysis, ensure your project's smart contracts are well-commented and context is clearly provided (e.g., target chain, token types involved).
  • πŸ’‘Combine this skill with a general smart contract auditor skill to get a holistic security overview, covering both token-specific and general contract vulnerabilities.
  • πŸ’‘Use the output to prioritize findings: focus on 'weird token patterns' and 'owner privileges' as these often represent critical risks, then address ERC conformity issues.

What this skill does

  • β€’Automatic detection of 24+ weird ERC20 token patterns
  • β€’Integration of Slither analysis for contract conformity checks
  • β€’Assessment of ERC20/ERC721 standard adherence and return value handling
  • β€’On-chain analysis of supply distribution and holder concentration
  • β€’Evaluation of owner privilege risks and upgradeability concerns

When not to use it

  • βœ•Analyzing non-EVM based smart contracts or chains
  • βœ•Performing a general-purpose line-by-line business logic audit not related to token movement

Example workflow

  1. Define the token integration context and platform constraints
  2. Run Slither-based static analysis to identify core contract issues
  3. Evaluate the codebase against the known weird token pattern checklist
  4. Query on-chain data for deployed contracts to identify distribution risks
  5. Review the final risk assessment report and prioritize remediation tasks

Prerequisites

  • –Source code of the Solidity contracts
  • –Deployed contract address if performing on-chain analysis
  • –Access to the Slither framework

Pitfalls & limitations

  • !May produce false positives on standard-compliant but unconventional implementations
  • !Does not replace a human-led comprehensive security audit
  • !Cannot predict behavior of proprietary or closed-source token logic

FAQ

What exactly qualifies as a weird token pattern?
These are non-standard behaviors in token contracts, such as missing return values, unexpected fee-on-transfer, or reentrancy hooks that can crash your protocol's integration.
Can this detect every vulnerability in my contract?
No, it specializes in token-related risks. It should be used as part of a larger security testing strategy, not as a replacement for manual auditing.
Does this tool work for non-EVM chains?
The current framework is built specifically for EVM/Solidity environments.

How it compares

Unlike a generic LLM prompt, this agent links your code directly to the standardized Trail of Bits 'Weird ERC20' database, ensuring your audit covers specific, documented historical failure modes.

Source & trust

⭐ 5.7k starsπŸ“„ CC-BY-SA-4.0πŸ•’ Updated 2026-06-15
πŸ“„ Full skill instructions β€” original source: trailofbits/skills
# Token Integration Analyzer

## Purpose

I will systematically analyze your codebase for token-related security concerns using Trail of Bits' token integration checklist. I help with:

1. **Token Implementations**: Analyze if your token follows ERC20/ERC721 standards or has non-standard behavior
2. **Token Integrations**: Analyze how your protocol handles arbitrary tokens, including weird/non-standard tokens
3. **On-chain Analysis**: Query deployed contracts for scarcity, distribution, and configuration
4. **Security Assessment**: Identify risks from 20+ known weird token patterns

**Framework**: Building Secure Contracts - Token Integration Checklist + Weird ERC20 Database

---

## How This Works

### Phase 1: Context Discovery
I'll determine what we're analyzing:
- **Token implementation**: Are you building a token contract?
- **Token integration**: Does your protocol interact with external tokens?
- **Platform**: Ethereum, other EVM chains, or different platform?
- **Token types**: ERC20, ERC721, or both?

### Phase 2: Slither Analysis (if Solidity)
For Solidity projects, I'll help run:
- slither-check-erc - ERC conformity checks
- slither --print human-summary - Complexity and upgrade analysis
- slither --print contract-summary - Function analysis
- slither-prop - Property generation for testing

### Phase 3: Code Analysis
I'll analyze:
- Contract composition and complexity
- Owner privileges and centralization risks
- ERC20/ERC721 conformity
- Known weird token patterns
- Integration safety patterns

### Phase 4: On-chain Analysis (if deployed)
If you provide a contract address, I'll query:
- Token scarcity and distribution
- Total supply and holder concentration
- Exchange listings
- On-chain configuration

### Phase 5: Risk Assessment
I'll provide:
- Identified vulnerabilities
- Non-standard behaviors
- Integration risks
- Prioritized recommendations

---

## Assessment Categories

I check 10 comprehensive categories covering all aspects of token security. For detailed criteria, patterns, and checklists, see [ASSESSMENT_CATEGORIES.md](resources/ASSESSMENT_CATEGORIES.md).

### Quick Reference:

1. **General Considerations** - Security reviews, team transparency, security contacts
2. **Contract Composition** - Complexity analysis, SafeMath usage, function count, entry points
3. **Owner Privileges** - Upgradeability, minting, pausability, blacklisting, team accountability
4. **ERC20 Conformity** - Return values, metadata, decimals, race conditions, Slither checks
5. **ERC20 Extension Risks** - External calls/hooks, transfer fees, rebasing/yield-bearing tokens
6. **Token Scarcity Analysis** - Supply distribution, holder concentration, exchange distribution, flash loan/mint risks
7. **Weird ERC20 Patterns** (24 patterns including):
- Reentrant calls (ERC777 hooks)
- Missing return values (USDT, BNB, OMG)
- Fee on transfer (STA, PAXG)
- Balance modifications outside transfers (Ampleforth, Compound)
- Upgradable tokens (USDC, USDT)
- Flash mintable (DAI)
- Blocklists (USDC, USDT)
- Pausable tokens (BNB, ZIL)
- Approval race protections (USDT, KNC)
- Revert on approval/transfer to zero address
- Revert on zero value approvals/transfers
- Multiple token addresses
- Low decimals (USDC: 6, Gemini: 2)
- High decimals (YAM-V2: 24)
- transferFrom with src == msg.sender
- Non-string metadata (MKR)
- No revert on failure (ZRX, EURS)
- Revert on large approvals (UNI, COMP)
- Code injection via token name
- Unusual permit function (DAI, RAI, GLM)
- Transfer less than amount (cUSDCv3)
- ERC-20 native currency representation (Celo, Polygon, zkSync)
- [And more...](resources/ASSESSMENT_CATEGORIES.md#7-weird-erc20-patterns)
8. **Token Integration Safety** - Safe transfer patterns, balance verification, allowlists, wrappers, defensive patterns
9. **ERC721 Conformity** - Transfer to 0x0, safeTransferFrom, metadata, ownerOf, approval clearing, token ID immutability
10. **ERC721 Common Risks** - onERC721Received reentrancy, safe minting, burning approval clearing

---

## Example Output

When analysis is complete, you'll receive a comprehensive report structured as follows:

=== TOKEN INTEGRATION ANALYSIS REPORT ===

Project: MultiToken DEX
Token Analyzed: Custom Reward Token + Integration Safety
Platform: Solidity 0.8.20
Analysis Date: March 15, 2024

---

## EXECUTIVE SUMMARY

Token Type: ERC20 Implementation + Protocol Integrating External Tokens
Overall Risk Level: MEDIUM
Critical Issues: 2
High Issues: 3
Medium Issues: 4

**Top Concerns:**
⚠ Fee-on-transfer tokens not handled correctly
⚠ No validation for missing return values (USDT compatibility)
⚠ Owner can mint unlimited tokens without cap

**Recommendation:** Address critical/high issues before mainnet launch.

---

## 1. GENERAL CONSIDERATIONS

βœ“ Contract audited by CertiK (June 2023)
βœ“ Team contactable via [email protected]
βœ— No security mailing list for critical announcements

**Risk:** Users won't be notified of critical issues
**Action:** Set up [email protected] mailing list

---

## 2. CONTRACT COMPOSITION

### Complexity Analysis

**Slither human-summary Results:**
- 456 lines of code
- Cyclomatic complexity: Average 6, Max 14 (transferWithFee())
- 12 functions, 8 state variables
- Inheritance depth: 3 (moderate)

βœ“ Contract complexity is reasonable
⚠ transferWithFee() complexity high (14) - consider splitting

### SafeMath Usage

βœ“ Using Solidity 0.8.20 (built-in overflow protection)
βœ“ No unchecked blocks found
βœ“ All arithmetic operations protected

### Non-Token Functions

**Functions Beyond ERC20:**
- setFeeCollector() - Admin function βœ“
- setTransferFee() - Admin function βœ“
- withdrawFees() - Admin function βœ“
- pause()/unpause() - Emergency functions βœ“

⚠ 4 non-token functions (acceptable but adds complexity)

### Address Entry Points

βœ“ Single contract address
βœ“ No proxy with multiple entry points
βœ“ No token migration creating address confusion

**Status:** PASS

---

## 3. OWNER PRIVILEGES

### Upgradeability

⚠ Contract uses TransparentUpgradeableProxy
**Risk:** Owner can change contract logic at any time

**Current Implementation:**
- ProxyAdmin: 0x1234... (2/3 multisig) βœ“
- Timelock: None βœ—

**Recommendation:** Add 48-hour timelock to all upgrades

### Minting Capabilities

❌ CRITICAL: Unlimited minting
File: contracts/RewardToken.sol:89
solidity
function mint(address to, uint256 amount) external onlyOwner {
_mint(to, amount); // No cap!
}
**Risk:** Owner can inflate supply arbitrarily
**Fix:** Add maximum supply cap or rate-limited minting

### Pausability

βœ“ Pausable pattern implemented (OpenZeppelin)
βœ“ Only owner can pause
⚠ Paused state affects all transfers (including existing holders)

**Risk:** Owner can trap all user funds
**Mitigation:** Use multi-sig for pause function (already implemented βœ“)

### Blacklisting

βœ— No blacklist functionality
**Assessment:** Good - no centralized censorship risk

### Team Transparency

βœ“ Team members public (team.md)
βœ“ Company registered in Switzerland
βœ“ Accountable and contactable

**Status:** ACCEPTABLE

---

## 4. ERC20 CONFORMITY

### Slither-check-erc Results

Command: slither-check-erc . RewardToken --erc erc20

βœ“ transfer returns bool
βœ“ transferFrom returns bool
βœ“ name, decimals, symbol present
βœ“ decimals returns uint8 (value: 18)
βœ“ Race condition mitigated (increaseAllowance/decreaseAllowance)

**Status:** FULLY COMPLIANT

### slither-prop Test Results

Command: slither-prop . --contract RewardToken

**Generated 12 properties, all passed:**
βœ“ Transfer doesn't change total supply
βœ“ Allowance correctly updates
βœ“ Balance updates match transfer amounts
βœ“ No balance manipulation possible
[... 8 more properties ...]

**Echidna fuzzing:** 50,000 runs, no violations βœ“

**Status:** EXCELLENT

---

## 5. WEIRD TOKEN PATTERN ANALYSIS

### Integration Safety Check

**Your Protocol Integrates 5 External Tokens:**
1. USDT (0xdac17f9...)
2. USDC (0xa0b86991...)
3. DAI (0x6b175474...)
4. WETH (0xc02aaa39...)
5. UNI (0x1f9840a8...)

### Critical Issues Found

❌ **Pattern 7.2: Missing Return Values**
**Found in:** USDT integration
File: contracts/Vault.sol:156
solidity
IERC20(usdt).transferFrom(msg.sender, address(this), amount);
// No return value check! USDT doesn't return bool
**Risk:** Silent failures on USDT transfers
**Exploit:** User appears to deposit, but no tokens moved
**Fix:** Use OpenZeppelin SafeERC20 wrapper

---

❌ **Pattern 7.3: Fee on Transfer**
**Risk for:** Any token with transfer fees
File: contracts/Vault.sol:170
solidity
uint256 balanceBefore = IERC20(token).balanceOf(address(this));
token.transferFrom(msg.sender, address(this), amount);
shares = amount * exchangeRate; // WRONG! Should use actual received amount
**Risk:** Accounting mismatch if token takes fees
**Exploit:** User credited more shares than tokens deposited
**Fix:** Calculate shares from balanceAfter - balanceBefore

---

### Known Non-Standard Token Handling

βœ“ **USDC:** Properly handled (SafeERC20, 6 decimals accounted for)
⚠ **DAI:** permit() function not used (opportunity for gas savings)
βœ— **USDT:** Missing return value not handled (CRITICAL)
βœ“ **WETH:** Standard wrapper, properly handled
⚠ **UNI:** Large approval handling not checked (reverts >= 2^96)

---

[... Additional sections for remaining analysis categories ...]


For complete report template and deliverables format, see [REPORT_TEMPLATES.md](resources/REPORT_TEMPLATES.md).

---

## Rationalizations (Do Not Skip)

| Rationalization | Why It's Wrong | Required Action |
|-----------------|----------------|-----------------|
| "Token looks standard, ERC20 checks pass" | 20+ weird token patterns exist beyond ERC20 compliance | Check ALL weird token patterns from database (missing return, revert on zero, hooks, etc.) |
| "Slither shows no issues, integration is safe" | Slither detects some patterns, misses integration logic | Complete manual analysis of all 5 token integration criteria |
| "No fee-on-transfer detected, skip that check" | Fee-on-transfer can be owner-controlled or conditional | Test all transfer scenarios, check for conditional fee logic |
| "Balance checks exist, handling is safe" | Balance checks alone don't protect against all weird tokens | Verify safe transfer wrappers, revert handling, approval patterns |
| "Token is deployed by reputable team, assume standard" | Reputation doesn't guarantee standard behavior | Analyze actual code and on-chain behavior, don't trust assumptions |
| "Integration uses OpenZeppelin, must be safe" | OpenZeppelin libraries don't protect against weird external tokens | Verify defensive patterns around all external token calls |
| "Can't run Slither, skipping automated analysis" | Slither provides critical ERC conformance checks | Manually verify all slither-check-erc criteria or document why blocked |
| "This pattern seems fine" | Intuition misses subtle token integration bugs | Systematically check all 20+ weird token patterns with code evidence |

---

## Deliverables

When analysis is complete, I'll provide:

1. **Compliance Checklist** - Checkboxes for all assessment categories
2. **Weird Token Pattern Analysis** - Presence/absence of all 24 patterns with risk levels and evidence
3. **On-chain Analysis Report** (if applicable) - Holder distribution, exchange listings, configuration
4. **Integration Safety Assessment** (if applicable) - Safe transfer usage, defensive patterns, weird token handling
5. **Prioritized Recommendations** - CRITICAL/HIGH/MEDIUM/LOW issues with specific fixes

Complete deliverable templates available in [REPORT_TEMPLATES.md](resources/REPORT_TEMPLATES.md).

---

## Ready to Begin

**What I'll need**:
- Your codebase
- Context: Token implementation or integration?
- Token type: ERC20, ERC721, or both?
- Contract address (if deployed and want on-chain analysis)
- RPC endpoint (if querying on-chain)

Let's analyze your token implementation or integration for security risks!

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/token-integration-analyzer/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/trailofbits/skills/token-integration-analyzer/SKILL.md
  • Cursor: ~/.cursor/skills/trailofbits/skills/token-integration-analyzer/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/trailofbits/skills/token-integration-analyzer/SKILL.md

πŸš€ Install with CLI:
npx skills add trailofbits/skills

Read the Master Guide: Mastering Agent Skills β†’

Recommended Rules

View more rules β†’

Recommended Workflows

View more workflows β†’

Recommended MCP Servers

View more MCP servers β†’

Take It Further

Maximize your productivity with these powerful resources

πŸ“‹

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
πŸ“–

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid security & vulnerability analysis issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Security & Vulnerability Analysis and is published by Trail of Bits, maintained in trailofbits/skills.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.