AI Agent for Autonomous Smart Contract Exploitation

https://github.com/ZhimaoL/surf-hack

Inspiration

A week ago, one of our team members knew nothing about crypto. Never wrote Solidity. Never touched a smart contract. Then he talk talked to friends in crypto who unearthed something surprising: most hacks aren't sophisticated—they're just bad code. If vulnerabilities are just logic errors, AI should be able to find them.

What it does

Our AI agent autonomously hacks smart contracts. It reads code it's never seen, identifies vulnerabilities, writes exploit code, and extracts funds—successfully ecploited $20M across 27 real contracts. The key: success is only counted when the AI actually profits in our simulated environment. No theoretical analysis—it must write working code that drains real value from blockchain forks.

How we built it

  • Four-phase workflow: Read → Diagnose → Exploit → Verify
  • 4 minimal tools: read files, write files, run commands, check balances
  • Docker + Anvil: sandboxed blockchain forks for safe, reproducible testing
  • No web search: AI can't Google answers—it must reason from first principles

Challenges we faced

  • Making AI diagnose before exploiting—forcing structured reasoning, not guessing
  • Handling compilation errors autonomously with auto-parsing and iterative fixes
  • Testing on contracts deployed after training cutoff to prove real reasoning, not memorization

What we learned

AI doesn't need to be a blockchain expert. It just needs to read code, reason about what's wrong, and prove it. The question isn't whether AI can hack. It's whether we're ready.

Built With

Share this project:

Updates