@jishankai/audit-cli
v1.0.0
Published
Smart contract security audit CLI tool using Slither, Mythril and AI
Maintainers
Readme
Smart Contract Audit CLI
An AI-powered smart contract security audit tool that combines multiple static analyzers (Slither & Mythril) with advanced AI models for comprehensive vulnerability detection.
Features
- Multiple Analyzers: Dual static analysis with Slither and Mythril for comprehensive coverage
- Multiple Source Options: Audit contracts from GitHub repositories or local files
- AI-Powered Analysis: OpenAI GPT-4.1 or Anthropic Claude analyzes contracts for 24+ vulnerability types
- Smart Provider Selection: Automatic fallback between AI providers based on API key availability
- Interactive CLI: User-friendly interface with inquirer.js and smart path autocomplete
- Path Autocomplete: Fuzzy search and navigation for selecting local paths and files
- Multiple Report Formats: Generates detailed Markdown, JSON, and PDF reports
- 24 Vulnerability Types: Covers all major smart contract security issues
- Robust Error Handling: Graceful failure handling with detailed error reporting
Vulnerability Coverage
Core Vulnerabilities
- Re-Entrancy - External calls before state updates
- Arithmetic Overflow and Underflow - Unchecked mathematical operations
- Self Destruct - Unprotected contract destruction
- Accessing Private Data - False assumptions about blockchain privacy
- Delegatecall - Dangerous context execution
- Source of Randomness - Manipulatable block variables
- Denial of Service - Gas limit exhaustion and blocking operations
- Phishing with tx.origin - Improper authorization checks
- Hiding Malicious Code with External Contract - Untrusted contract calls
- Front Running - Transaction order exploitation and MEV
- Block Timestamp Manipulation - Miner influence on time-dependent logic
- Signature Replay - Missing replay protection mechanisms
- Bypass Contract Size Check - Contract size manipulation
- Deploy Different Contracts at Same Address - CREATE2 exploits
Access Control & Authorization
- Unprotected Initializer - Upgradeable contract initialization attacks
- Missing Access Control - Unrestricted critical functions
- Centralization Risk - Single point of failure in privileged accounts
- Weak Access Control - Bypassable authentication mechanisms
Oracle & Price Manipulation
- Oracle Manipulation - Manipulable price sources and lack of TWAP
- Flash Loan Attack - State manipulation through flash loans
- Price Manipulation - AMM price control through large trades
DeFi Specific
- Insufficient Slippage Protection - Missing output amount validation
- Rounding Errors and Precision Loss - Mathematical calculation errors
- Token Approval Race Condition - ERC20 approve() double-spending
Proxy & Upgradability
- Uninitialized Proxy - Proxy implementation hijacking
- Storage Collision in Proxy - Storage layout corruption
- Function Selector Collision - Proxy function shadowing
- Constructor in Upgradeable Contract - Non-executed initialization
Token Issues
- Unchecked ERC20 Transfer Return Value - Silent transfer failures
- Fee-on-Transfer and Deflationary Token Issues - Accounting mismatches
- Rebasing Token Issues - Balance assumption violations
Logic & State
- Unchecked Low-Level Call Return Value - Silent call failures
- State Variable Shadowing - Inheritance variable conflicts
- Uninitialized State Variables - Default value exploitation
- Locked Ether - Permanent ether locking
Cross-Chain & Bridge
- Cross-Chain Replay Attack - Signature reuse across chains
- Insufficient Bridge Validation - Weak cross-chain message verification
MEV & Transaction Ordering
- MEV Vulnerability - Maximum extractable value exploits
- Transaction Ordering Dependence - Race conditions in resource allocation
Gas & DoS
- Gas Griefing - Excessive gas consumption attacks
- Unbounded Loop - Array iteration DoS
Miscellaneous Critical
- Unexpected Contract Balance and Forced Ether - Balance assumption violations
- Delegatecall to Arbitrary Address - Complete contract takeover
Total Coverage: 43 comprehensive vulnerability types covering all major smart contract security categories.
Prerequisites
- Node.js >= 16
- Python 3.8+
- Slither (install with:
pip3 install slither-analyzer) - Mythril (optional, install with:
pip3 install mythril) - AI API Key (choose one):
- OpenAI API Key (for GPT-4.1 - default)
- Anthropic API Key (for Claude)
Installation
# Clone the repository
git clone <repository-url>
cd audit-cli
# Install dependencies
npm install
# Build the project
npm run build
# Set up environment variables
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEYUsage
Interactive Mode (Recommended)
npm startThe CLI will guide you through:
- Selecting source type (GitHub or Local)
- Providing the source path/URL
- Optionally selecting a specific file
- Choosing vulnerability types to check
- Selecting report formats (Markdown, JSON, PDF)
- Setting output directory
Environment Variables
The tool supports both OpenAI GPT and Anthropic Claude models with intelligent fallback. By default, it uses OpenAI with GPT-4.1.
Quick Setup (Option 1): Using OpenAI GPT-4.1 (Default)
export OPENAI_API_KEY=your_openai_key_hereQuick Setup (Option 2): Using Anthropic Claude
export ANTHROPIC_API_KEY=your_anthropic_key_hereAdvanced Configuration
# Specify AI provider explicitly
export AI_PROVIDER=anthropic # or 'openai'
# Use specific models
export OPENAI_MODEL=gpt-5.2
export ANTHROPIC_MODEL=claude-3-opus-20240229Create .env file for convenience:
cp .env.example .env
# Edit .env with your API keysAvailable Models:
- OpenAI:
gpt-4.1(default),gpt-5.2and more - Anthropic:
claude-sonnet-4-20250514(default),claude-3-opus-20240229,claude-3-sonnet-20240229and more
Smart Fallback: The tool automatically detects available API keys and uses the appropriate provider. If you provide both keys, it uses the provider specified by AI_PROVIDER or defaults to OpenAI.
Example Workflow
Start the audit tool:
npm startSelect source type:
GitHub RepositoryorLocal Directory/FileEnter the path:
- GitHub:
https://github.com/username/repo - Local:
/path/to/contracts
- GitHub:
Choose vulnerability checks (use spacebar to select)
Wait for analysis to complete
Review the generated report in
./reports/
Report Output
The tool generates comprehensive reports in your selected formats:
audit-report-{timestamp}.md: Human-readable Markdown reportaudit-report-{timestamp}.json: Machine-readable JSON reportaudit-report-{timestamp}.pdf: Professional PDF report with styled formatting
PDF Report Features
- Professional styling with color-coded severity levels
- Print-optimized layout with proper page breaks
- Syntax-highlighted code blocks
- Clean, corporate-ready format for sharing with clients or stakeholders
Report Sections
- Executive Summary: Overview of findings by severity across all analyzers
- Critical/High/Medium/Low Findings: Detailed vulnerability reports from both Slither and Mythril
- Static Analysis Results:
- Slither Analysis: Comprehensive static analysis with IR extraction
- Mythril Analysis: Symbolic execution analysis for deeper security insights
- AI Analysis: Advanced vulnerability assessment using GPT-4.1 or Claude
- Recommendations: Prioritized remediation steps based on aggregated findings
Multi-Analyzer Benefits
- Broader Coverage: Slither excels at detecting common vulnerabilities, while Mythril finds complex state-dependency issues
- Reduced False Positives: Cross-validation between analyzers improves accuracy
- Comprehensive Insights: Different analysis techniques provide complementary security perspectives
Development
# Development mode with auto-reload
npm run dev
# Build TypeScript
npm run build
Project Structure
audit-cli/
├── src/
│ ├── index.ts # Entry point with CLI initialization
│ ├── cli.ts # Interactive CLI interface
│ ├── orchestrator.ts # Main audit orchestration logic
│ ├── analyzers/ # Static analysis tools
│ │ ├── base.ts # Base analyzer interface
│ │ ├── slither.ts # Slither integration
│ │ └── mythril.ts # Mythril integration
│ ├── auditor/ # AI-powered analysis
│ ├── fetcher/ # Source code fetching
│ ├── vulnerabilities/ # Vulnerability knowledge base
│ ├── reporter/ # Multi-format report generation
│ └── types/ # TypeScript type definitions
├── samples/ # Sample smart contracts for testing
├── package.json
├── tsconfig.json
├── .env.example # Environment configuration template
└── README.mdAdvanced Usage
Custom Vulnerability Selection
The interactive CLI allows you to select specific vulnerability types to analyze. Use spacebar to select/deselect items and arrow keys to navigate.
Running Multiple Analyzers
Both Slither and Mythril run automatically when available. If one analyzer fails or isn't installed, the tool continues with the available analyzers and reports the status of each.
Debug Mode
Set DEBUG=true in your environment to see detailed stack traces and analyzer output for troubleshooting.
Performance Tips
- Install Mythril for more comprehensive analysis
- Use SSD storage for faster file operations
- Ensure stable internet connection for GitHub repository cloning
- Consider using specific vulnerability types for faster analysis on large codebases
Security Notes
- This tool is designed for authorized security testing and educational purposes
- Results should be verified by security professionals
- AI analysis complements but does not replace human expertise
- Always perform manual code review in addition to automated analysis
Limitations
- Slither must be installed and accessible in PATH (Mythril is optional but recommended)
- Requires AI API key (OpenAI or Anthropic) for advanced analysis
- Analysis quality depends on code complexity and documentation quality
- Some vulnerabilities may require manual verification for complete accuracy
- Large repositories may require longer analysis times due to dual analyzer approach
- Network dependencies are required for GitHub repository cloning
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- Create an issue on GitHub
- Check existing documentation
- Review Slither documentation: https://github.com/crytic/slither
Acknowledgments
- Slither by Trail of Bits - Static analysis framework
- Mythril by ConsenSys - Symbolic execution analysis
- OpenAI - GPT-4.1 language model
- Anthropic - Claude language models
- inquirer.js - Interactive command line interface
- Node.js ecosystem - All the amazing open-source dependencies
