🏆 Built for the Auto-Research Hackathon
ChinaSec is an AI-powered security research system that autonomously discovers vulnerabilities in DeFi smart contracts using an iterative research loop — not a fixed checklist.
Most AI security tools do a single pass: scan code → list issues → done. ChinaSec is different. It runs a self-directed research loop that gets smarter with each iteration:
🌱 Seed Questions
↓
🔍 Discover → 📊 Analyze → 💡 Hypothesize → ✅ Verify → 🔄 Refine
↑ ↓
└─────────── NEW deeper questions emerge ←────────────────┘
↓
📉 Converge & Report
| Traditional Agent | 🔬 ChinaSec Loop |
|---|---|
| Fixed chain of prompts | Self-directed investigation |
| One-pass analysis | Iterative deepening (3-10 cycles) |
| No memory between steps | Knowledge graph accumulates across iterations |
| Predefined checklist | Questions emerge from findings |
| Reports everything | Hypothesize → Verify → only report confirmed exploits |
| Doesn't know when to stop | Convergence detection (stops when learning rate drops) |
┌──────────────────────────────────────────────────┐
│ Research Loop Engine │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Planner │ │ Analyzer │ │ Verifier │ │
│ │ (brain) │ │ (auditor)│ │ (adversarial)│ │
│ └────┬─────┘ └────┬─────┘ └──────┬───────┘ │
│ │ │ │ │
│ └──────────────┼───────────────┘ │
│ │ │
│ ┌───────▼───────┐ │
│ │ Knowledge │ │
│ │ Graph │ │
│ │ (accumulates) │ │
│ └───────────────┘ │
└──────────────────────────────────────────────────┘
│ │
┌────▼─────┐ ┌──────▼──────┐
│ Fetchers │ │ Reports │
│ Etherscan│ │ Markdown │
│ GitHub │ │ + JSON │
│ Local │ └─────────────┘
└──────────┘
-
🧭 Research Planner — The brain. Generates research questions, prioritizes investigations, decides what to dig into next. Balances breadth (covering all vuln classes) with depth (following promising leads).
-
🔍 Vulnerability Analyzer — The auditor. Examines contract code against a taxonomy of 10 known DeFi vulnerability classes (reentrancy, oracle manipulation, flash loans, access control, etc.).
-
⚔️ Hypothesis Verifier — The adversary. Tries to construct specific attack scenarios for each hypothesis. Skeptical by default — looks for guards and protections that would block the exploit.
-
📚 Knowledge Graph — The memory. Accumulates findings, hypotheses, and confirmed vulnerabilities across iterations. Feeds a compressed summary into every LLM call so each iteration builds on all prior work.
-
📉 Convergence Detector — The stop signal. Tracks the "new information ratio" per iteration. When the system stops learning new things (ratio drops below threshold for 2 consecutive iterations), it stops and reports.
| Class | Severity | Historical Examples |
|---|---|---|
| 🔄 Reentrancy | Critical | The DAO ($60M), Curve (2023) |
| 📈 Oracle Manipulation | Critical | Harvest ($34M), Mango ($114M) |
| ⚡ Flash Loan Attacks | Critical | bZx, Pancake Bunny ($45M) |
| 🔐 Access Control | High | Parity wallet, Wormhole ($320M) |
| 🏛️ Governance Attacks | High | Beanstalk ($182M) |
| 🔢 Integer Overflow | High | Multiple pre-0.8 exploits |
| 🏃 Front-Running / MEV | Medium | Sandwich attacks |
| 🧮 Logic Errors | High | Fee/reward miscalculations |
| 🔗 Cross-Contract Issues | High | Composability exploits |
| 🚫 Denial of Service | Medium | Gas griefing |
# 1. Clone and install
git clone <this-repo>
cd hack-paradigm-proj
uv sync
# 2. Configure
cp .env.example .env
# Edit .env with your API key and model settings
# 3. Run against an Etherscan contract
uv run autoresearch 0x44fbeBd2F576670a6C33f6Fc0B00aA8c5753b322
# 4. Or a GitHub repo
uv run autoresearch https://github.com/some-protocol/contracts
# 5. Or the included demo contract
uv run autoresearch ./examples/See deploy.md for detailed setup instructions.
┌─────────────────────────────────────────────────┐
│ Auto-Research DeFi Security Scanner │
│ Target: ./examples/ │
│ Model: gpt-4o @ https://api.openai.com/v1 │
│ Max iterations: 10 │
└─────────────────────────────────────────────────┘
Iteration 1: 5 questions → 8 findings → 3 hypotheses
Iteration 2: 4 questions → 6 findings → 2 hypotheses (1 confirmed!)
Iteration 3: 3 questions → 4 findings → 1 hypothesis (2 confirmed!)
Iteration 4: 2 questions → 1 finding → converged
┌─────────────────────────────────────────────────┐
│ Research Complete │
│ Iterations: 4 │
│ Questions investigated: 22 │
│ Confirmed vulnerabilities: 5 │
│ Unverified hypotheses: 2 │
└─────────────────────────────────────────────────┘
[CRITICAL] reentrancy: withdraw() sends ETH before updating state
[CRITICAL] price_oracle_manipulation: slot0() used as price feed
[HIGH] access_control: initialize() callable by anyone
[HIGH] governance_attack: flash-loanable voting power
[MEDIUM] logic_error: first depositor share manipulation
Iteration 1 asks broad questions → finds surface-level patterns.
Iteration 2 asks "Can the reentrancy in withdraw() actually be exploited given the token's transfer behavior?" — a question that only exists because iteration 1 found the pattern.
Iteration 3 asks "If reentrancy is confirmed, can it be combined with the oracle manipulation to amplify the attack?" — cross-cutting analysis that emerges from the accumulated knowledge.
The knowledge graph prevents wasted work — refuted hypotheses are marked so the system never re-investigates dead ends.
- Python 3.12+ with async/await for parallel analysis
- OpenAI SDK (compatible with any provider: OpenAI, Anthropic, local models)
- Pydantic for structured LLM outputs and data validation
- Rich for terminal UI
- httpx for async HTTP (Etherscan + GitHub fetching)
MIT