AI-powered smart contract auditor that analyzes Solidity code and explains vulnerabilities like a security engineer.
OpenAudit AI combines static analysis with LLM-powered explanations to help developers find and understand security issues in their Solidity smart contracts.
- ๐ Static Analysis Engine โ Parses Solidity source and runs modular vulnerability detection rules
- ๐ Reentrancy Detection โ Identifies external calls made before state updates
โ ๏ธ Unchecked Call Detection โ Flags low-level.call()results that aren't validated- ๐ค AI Explanations โ Uses GPT-5 to explain vulnerabilities in plain English (optional; works without an API key)
- ๐ป CLI Tool โ
oauditcommand for single-file analysis and directory scanning - ๐ฉบ Diagnostics โ
oaudit doctorto check your AI configuration at a glance - ๐ JSON Output โ Machine-readable output for CI/CD integration
- ๐งฉ Extensible Rule System โ Add new detectors by subclassing
BaseRule - ๐ Fail-Safe โ Never crashes due to AI issues; gracefully falls back to templates
# Clone the repository
git clone https://github.com/openaudit-ai/openaudit-ai.git
cd openaudit-ai
# Install in development mode
pip install -e ".[dev]"Analyze a single contract:
oaudit analyze examples/vulnerable_bank.solScan an entire directory:
oaudit scan ./contracts/Get JSON output:
oaudit analyze contract.sol --jsonSkip AI explanations (no API key needed):
oaudit analyze contract.sol --no-aiCheck your configuration:
oaudit doctorOpenAudit AI reads configuration from a .env file in the project root (or from environment variables).
cp .env.example .env
# Edit .env and add your OpenAI API keyThe .env file supports these variables:
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY |
For AI explanations | โ | Your OpenAI API key |
OPENAI_BASE_URL |
No | https://api.openai.com/v1 |
API endpoint (change for Azure, local proxies, etc.) |
OPENAI_MODEL |
No | gpt-5-mini |
Model used for explanations |
Set the model in .env:
OPENAI_MODEL=gpt-5-mini
Available models: gpt-5.2, gpt-5.2-pro, gpt-5.1, gpt-5, gpt-5-mini, gpt-5-nano
Or override per-command with --model:
oaudit analyze contract.sol --model gpt-5.2The CLI flag takes priority over the .env value.
If the configured model is unavailable (API error, model not found), the tool automatically falls back to gpt-4o-mini.
Skip AI explanations entirely (no API key needed):
oaudit analyze contract.sol --no-aiWhen no OPENAI_API_KEY is set, the tool automatically uses built-in template explanations โ it never crashes due to missing AI configuration.
oaudit doctorExample output:
OpenAudit AI โ Configuration Diagnostic
AI Provider: OpenAI
Model: gpt-5-mini
API Key: detected
Base URL: https://api.openai.com/v1
Fallback Mode: disabled
oaudit analyze <file.sol> ๐ Analyze a single Solidity file
oaudit scan <directory> ๐ Scan all .sol files in a directory
oaudit doctor ๐ฉบ Diagnose AI provider configuration
oaudit version ๐ Show version
| Flag | Description |
|---|---|
--json / -j |
๐ Output results as JSON |
--no-ai |
๐ซ Skip AI-powered explanations |
--model / -m |
๐ค Specify the LLM model to use |
โ ๏ธ Reentrancy Vulnerability
Severity: HIGH
Location: line 25
In function `withdraw()`: external call on line 25 occurs before
state update on line 28. The call target `msg.sender` could
re-enter this function before `balances` is updated.
โญโโโโโโโโโโโโโโโโโโโ AI Explanation โโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ The contract sends ETH before updating the user's โ
โ balance. An attacker contract could repeatedly call โ
โ withdraw() via its fallback function, draining the โ
โ contract. โ
โ โ
โ Fix: Apply the checks-effects-interactions pattern โ
โ or use OpenZeppelin's ReentrancyGuard. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
openaudit-ai/
โโโ openaudit/
โ โโโ config.py โ๏ธ Centralized configuration (.env + defaults)
โ โโโ cli/ ๐ป CLI commands (Typer)
โ โโโ analyzer/ ๐ Static analysis engine & parser
โ โโโ rules/ ๐ Vulnerability detection rules
โ โโโ ai/ ๐ค LLM integration & prompt templates
โ โโโ reports/ ๐ Output formatting (terminal, JSON)
โ โโโ utils/ ๐ง Shared types & helpers
โ โโโ api/ ๐ Future REST API (FastAPI)
โโโ tests/ ๐งช pytest test suite (32 tests)
โโโ examples/ ๐ Sample vulnerable contracts
โโโ docs/ ๐ Architecture deep-dive
โโโ .env.example ๐ Environment variable template
โโโ pyproject.toml ๐ฆ Package configuration
- Create a file in
openaudit/rules/:
from openaudit.rules.base import BaseRule
from openaudit.rules.registry import register
@register
class MyRule(BaseRule):
id = "my-rule"
title = "My Custom Rule"
description = "Detects ..."
def run(self, ast, source):
findings = []
# Your detection logic here
return findings-
Import it in
openaudit/rules/registry.pyinside_discover_rules(). -
Add a template in
openaudit/ai/provider.pyFallbackProvider._TEMPLATES.
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=openaudit
# Lint
ruff check openaudit/ tests/- ๐ Additional rules (integer overflow, tx.origin, selfdestruct, etc.)
- ๐ REST API via FastAPI
- ๐ค GitHub PR bot for automated reviews
- ๐ Hosted service with dashboard
- ๐ณ tree-sitter based Solidity parser
- ๐ Multi-file / import resolution support
- ๐ Slither integration bridge
See CONTRIBUTING.md for guidelines.
