A comprehensive vulnerability scanner specifically designed for Solidity smart contracts. This tool performs automated security audits, identifies common vulnerabilities, and provides detailed reports with remediation recommendations.
Features
- Static Analysis - Automated code review for common Solidity vulnerabilities
- Vulnerability Detection - Identifies reentrancy, overflow, access control issues
- Gas Optimization - Analyzes gas usage and suggests optimizations
- Best Practices - Checks compliance with Solidity best practices
- Detailed Reporting - Generates comprehensive audit reports
- Integration - CI/CD pipeline integration for automated scanning
- Custom Rules - Support for custom security rules and patterns
- Multi-Contract Analysis - Analyzes entire contract ecosystems
Detected Vulnerabilities
Critical Issues
- Reentrancy Attacks - Detects potential reentrancy vulnerabilities
- Integer Overflow/Underflow - Identifies arithmetic operation risks
- Access Control - Checks for proper access control mechanisms
- Unchecked External Calls - Flags dangerous external interactions
High Priority Issues
- Gas Optimization - Identifies inefficient gas usage patterns
- Storage Optimization - Suggests storage layout improvements
- Function Visibility - Checks for proper function visibility settings
- Event Emission - Validates proper event emission for transparency
Medium Priority Issues
- Code Quality - Identifies code smells and anti-patterns
- Documentation - Checks for proper NatSpec documentation
- Naming Conventions - Validates Solidity naming standards
- Import Organization - Suggests better import structuring
Tech Stack
- Language: Python 3.8+
- Analysis Engine: Custom Solidity parser and analyzer
- Vulnerability Database: Curated database of known vulnerabilities
- Reporting: HTML, JSON, and Markdown report formats
- Integration: GitHub Actions, GitLab CI, Jenkins support
Installation
-
Clone the repository:
git clone https://github.com/1cbyc/secure-audit-tool.git cd secure-audit-tool
-
Install dependencies:
pip install -r requirements.txt
-
Run the scanner:
python audit_tool.py --contract path/to/contract.sol
Usage Examples
Basic Scan
python audit_tool.py --contract contracts/Token.sol
Comprehensive Analysis
python audit_tool.py \
--contract contracts/ \
--output report.html \
--severity critical,high \
--include-gas-analysis
CI/CD Integration
# GitHub Actions example
- name: Security Audit
run: |
python audit_tool.py --contract contracts/ --output audit-report.json
python audit_tool.py --validate-report audit-report.json --max-critical 0
Sample Report Output
{
"contract": "Token.sol",
"scan_date": "2024-03-10T10:30:00Z",
"vulnerabilities": [
{
"severity": "critical",
"type": "reentrancy",
"line": 45,
"description": "Potential reentrancy vulnerability in withdraw function",
"recommendation": "Use ReentrancyGuard or checks-effects-interactions pattern"
},
{
"severity": "high",
"type": "access_control",
"line": 23,
"description": "Missing access control on admin function",
"recommendation": "Add onlyOwner modifier or proper access control"
}
],
"gas_analysis": {
"total_gas": 150000,
"optimization_opportunities": 3,
"estimated_savings": "25%"
}
}
Security Rules Engine
The tool includes a comprehensive rules engine that checks for:
Solidity-Specific Issues
- Reentrancy Patterns - Detects common reentrancy attack vectors
- Access Control - Validates proper access control mechanisms
- State Management - Checks for proper state variable handling
- External Interactions - Analyzes external contract calls
Gas Optimization
- Storage Layout - Optimizes storage variable arrangement
- Function Optimization - Suggests gas-efficient function patterns
- Loop Optimization - Identifies inefficient loop patterns
- Memory Usage - Optimizes memory allocation and usage
Integration Capabilities
CI/CD Pipelines
- GitHub Actions - Automated scanning on pull requests
- GitLab CI - Integration with GitLab pipelines
- Jenkins - Custom Jenkins pipeline support
- Azure DevOps - Azure pipeline integration
Development Tools
- VS Code Extension - Real-time vulnerability detection
- IDE Integration - Support for popular IDEs
- Pre-commit Hooks - Automated scanning before commits
- API Integration - RESTful API for custom integrations
Project Impact
This tool has been used by:
- DeFi Protocols - Auditing smart contracts before deployment
- Security Firms - Supporting manual audit processes
- Developers - Learning and improving smart contract security
- Educational Institutions - Teaching blockchain security concepts
Future Enhancements
- Machine Learning - AI-powered vulnerability detection
- Formal Verification - Integration with formal verification tools
- Multi-Language Support - Support for other smart contract languages
- Real-time Monitoring - Continuous monitoring of deployed contracts
- Advanced Reporting - Interactive vulnerability reports with remediation guides