ryzen404/smart-contract-auditor

GitHub: ryzen404/smart-contract-auditor

基于多 Agent AI 架构的 Solidity 智能合约审计系统,从安全漏洞、Gas 优化和最佳实践三个维度提供自动化分析与风险评分。

Stars: 0 | Forks: 0

# SmartContract AI 审计员 分析 Solidity 智能合约安全漏洞、gas 优化和最佳实践的多 Agent AI 系统。 ## 在线演示 **[smart-contract-auditor-three.vercel.app](https://smart-contract-auditor-three.vercel.app/)** ![Landing Page](https://static.pigsec.cn/wp-content/uploads/repos/cas/04/04ce7b3d213ea12ca074cad740b997ae34c3111f1db8b745ddb58ea753561ca6.png) ![Audit Results](https://static.pigsec.cn/wp-content/uploads/repos/cas/06/0631e96a3622c531602c12519f0a5b63b66e24f367c46518d06fc6ab44bb2c07.png) ## 功能 - **Security Agent** — 检测重入、访问控制问题、整数溢出、不安全转账、缺失事件和零金额检查 - **Gas Agent** — 识别存储打包机会、calldata 优化、未检查算术以及部署成本降低方案 - **Best Practices Agent** — 检查 NatSpec 文档、事件触发、Pausable 实现和输入验证 - **风险评分** — 0-100 分制,附带严重/高/中/低风险分类 - **修复建议** — 为每个发现提供可操作的补救措施 - **代码高亮** — 精确指出存在漏洞的代码行并附带修复上下文 ## 工作原理 ### Pipeline 1. **输入** — 将 Solidity 合约代码粘贴到编辑器中 2. **解析** — 提取函数、状态变量、导入、modifier 和事件 3. **分析** — 三个专家 Agent 并行运行: - **Security Agent** — 漏洞检测 - **Gas Agent** — 优化机会 - **Best Practices Agent** — 代码质量检查 4. **评分** — 将发现的结果汇总为 0-100 的风险评分 5. **报告** — 显示发现的漏洞、严重程度、受影响代码行以及修复建议 ### 评分 | 严重程度 | 扣分 | |----------|-----------| | 严重 (Critical) | -25 | | 高 (High) | -15 | | 中 (Medium) | -8 | | 低 (Low) | -3 | | 分数 | 风险等级 | |---------|------------| | 80-100 | 低 | | 60-79 | 中 | | 40-59 | 高 | | 0-39 | 严重 | ### Security Agent - 重入(状态更新前的外部调用) - 缺少访问控制(没有 modifier 的 public 函数) - 不安全的 ETH 转账(.transfer/.send 与 .call 的对比) - 用户可控算术中的整数溢出 - 状态更改缺失事件触发 - 零金额验证缺失 ### Gas Agent - 存储变量打包(slot 优化) - 只读参数的 memory 与 calldata 对比 - 安全操作的 unchecked 算术 - public 与 external 函数可见性对比 - 部署成本优化 ### Best Practices Agent - NatSpec 文档覆盖率 - 所有状态更改的事件定义 - Pausable 紧急机制 - 零地址输入验证 - 提款模式与推送模式对比 - ReentrancyGuard 使用 ## 技术栈 - Next.js 15 (App Router) - TypeScript - 客户端分析(无需后端) ## 本地运行 ``` npm install npm run dev ``` 打开 [http://localhost:3000](http://localhost:3000) ## 为小米 MiMo 100T 创作者计划打造 多 Agent 架构展示了用于智能合约安全分析的长链推理与专业 AI Agent 协作。 ## 许可证 MIT
标签:PyRIT, Solidity, Web3安全, 云安全监控, 多智能体系统, 智能合约审计, 自动化攻击, 静态分析