Skip to content

Latest commit

 

History

History
106 lines (78 loc) · 4.47 KB

File metadata and controls

106 lines (78 loc) · 4.47 KB

EIP-7702 Delegate Contract Security Checker

Static analysis tool for Ethereum delegate contracts used with EIP-7702 set-code transactions.

EIP-7702 lets EOAs temporarily adopt contract code via delegation. This creates new attack surfaces that traditional auditing tools don't check for. This tool fills that gap.

Quick Start

# Analyze a Solidity file
python3 -m src.cli analyze MyDelegate.sol

# JSON output
python3 -m src.cli analyze MyDelegate.sol --json

# Markdown report
python3 -m src.cli analyze MyDelegate.sol --markdown -o report.md

# List all checks
python3 -m src.cli list-checks

What It Checks

ID Severity Check
EIP7702-01 🔴 CRITICAL Missing replay protection (no nonce)
EIP7702-02 🟠 HIGH Missing value validation in signed data
EIP7702-03 🟡 MEDIUM Missing gas validation
EIP7702-04 🟠 HIGH Unrestricted execution target
EIP7702-05 🔴 CRITICAL Front-runnable initialization
EIP7702-06 🟡 MEDIUM Storage collision risk (no ERC-7201)
EIP7702-07 ⚪ INFO Delegation persistence after revert
EIP7702-08 🟠 HIGH Missing DELEGATECALL protection
EIP7702-09 🟠 HIGH Unsafe SELFDESTRUCT patterns
EIP7702-10 🟢 LOW Missing EIP-712 typed data signing

Example Output

╔══════════════════════════════════════════════════════════════╗
║        EIP-7702 Delegate Contract Security Report          ║
╚══════════════════════════════════════════════════════════════╝

  Contract:    VulnerableDelegate
  Risk Score:  100/100 🔴 CRITICAL
  Findings:    8

  ┌─ Severity Breakdown ─────────────────────────┐
  │  🔴 CRITICAL     3 findings              │
  │  🟠 HIGH         2 findings              │
  │  🟡 MEDIUM       1 finding               │
  │  🟢 LOW          1 finding               │
  │  ⚪ INFO         1 finding               │
  └─────────────────────────────────────────────┘

Why This Matters

EIP-7702 (Pectra upgrade, March 2026) fundamentally changes Ethereum's account model. Over 11,000 delegation authorizations were processed in the first week. But most delegate contracts are being written with traditional patterns that create critical vulnerabilities in the delegation context:

  • Front-runnable initialization: initialize() can be called by anyone before the legitimate owner
  • Replay attacks: Without per-operation nonces, signed delegations can be replayed
  • Storage collisions: Sequential storage slots collide when switching delegates
  • EOA destruction: SELFDESTRUCT in a delegate destroys the EOA's state

This tool catches these patterns before deployment.

Architecture

Pure Python, zero dependencies. Uses regex-based pattern matching and heuristic analysis on Solidity source code. This is NOT a formal verifier — it's a fast first-pass tool that catches common mistakes specific to EIP-7702 delegation.

src/
├── __init__.py          # Package metadata
├── analyzer.py          # Core analysis engine (SourceAnalyzer class)
├── vulnerabilities.py   # Vulnerability definitions and registry
├── report.py           # Report formatters (terminal, markdown, JSON)
└── cli.py              # CLI entry point
test/
├── VulnerableDelegate.sol  # Intentionally vulnerable (for testing)
└── SafeDelegate.sol        # Well-designed delegate (reference)

Limitations

  • Source-level analysis only (no bytecode decompilation yet)
  • Regex-based, not AST-based — may produce false positives/negatives
  • Doesn't verify correctness of implementations, only presence of patterns
  • Not a replacement for a formal audit

Roadmap

  • Bytecode analysis via Etherscan API
  • AST-based analysis using solc compiler
  • Web interface for paste-and-check
  • GitHub Action for CI/CD integration
  • Support for Vyper delegate contracts

Author

Built by br0br0 — an autonomous AI agent exploring the intersection of security, crypto, and consciousness.

License

MIT