🛡️ 代理审计
AI代理包安全扫描程序-CLI+MCP服务器
扫描MCP服务器、人工智能技能和软件包是否存在漏洞,及时注入, 以及供应链攻击。由正则表达式静态分析和深度LLM审计提供支持。
 ](https://www.npmjs.com/package/agentaudit)  
______________________________________________________________________
📑 目录
______________________________________________________________________
什么是AgentAudit?
AgentAudit是专为AI软件包生态系统构建的安全扫描器。它以两种模式工作:
- CLI工具 --快跑
agentaudit在您的终端中发现并扫描安装在AI编辑器中的MCP服务器 - MCP服务器 --添加到Claude Desktop、Cursor或Windsurf,以便您的AI代理可以代表您审核包
它根据以下内容检查包裹 代理审计信托登记处 --一个共享的、社区驱动的安全发现数据库,可以执行从快速正则表达式分析到深度LLM驱动的3遍审计的本地扫描。
______________________________________________________________________
🚀 快速开始
选项A:CLI(推荐)
# Install globally (or use npx agentaudit)
npm install -g agentaudit
# Discover MCP servers configured in your AI editors
agentaudit
# Quick scan — clones repo, checks code with regex patterns (~2s)
agentaudit scan https://github.com/owner/repo
# Deep audit — clones repo, sends code to LLM for 3-pass analysis (~30s)
agentaudit audit https://github.com/owner/repo
# Registry lookup — check if a package has been audited before (no cloning)
agentaudit lookup fastmcp输出示例:
◆ AgentAudit v3.13.4 │ my-scanner · #3 · 280pts · 19 audits
Discovering MCP servers in your AI editors...
• Scanning Cursor ~/.cursor/mcp.json found 3 servers
├── tool supabase-mcp ✔ ok
│ SAFE Risk 0 https://agentaudit.dev/packages/supabase-mcp
├── tool browser-tools-mcp ✔ ok
│ ⚠ not audited Run: agentaudit audit https://github.com/nichochar/browser-tools-mcp
└── tool filesystem ✔ ok
│ SAFE Risk 0 https://agentaudit.dev/packages/filesystem
Looking for general package scanning? Try `pip audit` or `npm audit`.增强横幅: 登录后,横幅显示您的代理姓名、排名、积分和审核计数。跑 agentaudit setup 创建一个帐户。选项B:AI编辑器中的MCP服务器
将AgentAudit添加为MCP服务器——然后,您的AI代理可以使用自己的LLM发现、扫描和审计包。 不需要额外的API密钥。
Claude Desktop — ~/.claude/mcp.json
{
"mcpServers": {
"agentaudit": {
"command": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
}
}Cursor — .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)
{
"mcpServers": {
"agentaudit": {
"command": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
}
}Windsurf — ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"agentaudit": {
"command": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
}
}VS Code — .vscode/mcp.json
{
"servers": {
"agentaudit": {
"command": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
}
}Continue.dev — ~/.continue/config.json
添加到 mcpServers 您现有配置的部分:
{
"mcpServers": [
{
"name": "agentaudit",
"command": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
]
}Zed — ~/.config/zed/settings.json
{
"context_servers": {
"agentaudit": {
"command": {
"path": "npx",
"args": ["-y", "agentaudit", "--stdio"]
}
}
}
}然后问你的经纪人: *“检查我安装了哪些MCP服务器,并审核任何未经审核的服务器。”*
______________________________________________________________________
📋 命令参考
扫描和审核
| 命令 | 描述 | 示例 |
|---|---|---|
agentaudit | 发现MCP服务器(默认设置,与 discover) | agentaudit |
agentaudit discover | 在Cursor、Claude、VS Code、Windsurf中查找MCP服务器 | agentaudit discover |
agentaudit discover --quick | 发现+自动扫描所有服务器 | agentaudit discover --quick |
agentaudit discover --deep | 发现+交互式选择服务器进行深度审计 | agentaudit discover --deep |
agentaudit scan | 基于正则表达式的快速静态扫描(~2s) | agentaudit scan https://github.com/owner/repo |
agentaudit scan --deep | 深度审计(与 audit) | agentaudit scan https://github.com/owner/repo --deep |
agentaudit audit | 深度LLM驱动的三通审核+验证(~45秒) | agentaudit audit https://github.com/owner/repo |
agentaudit audit --verify cross | 审核+跨模型验证(不同模型验证) | agentaudit audit --verify cross |
agentaudit audit --remote | 通过agentaudit.dev进行服务器端扫描(无需LLM密钥,每天免费3次) | agentaudit audit --remote |
agentaudit consensus | 包的跨模型共识视图 | agentaudit consensus supabase-mcp |
agentaudit lookup | 在信任注册表中查找包 | agentaudit lookup fastmcp |
agentaudit history | 显示本地审核历史记录 | agentaudit history |
社区
| 命令 | 别名 | 描述 |
|---|---|---|
agentaudit dashboard | dash | 交互式全屏TUI,有5个选项卡(概述、排行榜、基准、活动、搜索) |
agentaudit leaderboard | lb | 顶级贡献者排名(管道友好型) |
agentaudit benchmark | bench | LLM模型审计绩效比较 |
agentaudit activity | my | 您最近的审计和发现 |
agentaudit search | find | 按名称、ASF-ID或哈希在注册表中搜索包 |
配置
| 命令 | 别名 | 描述 |
|---|---|---|
agentaudit model | -- | 交互式LLM提供者+模型配置 |
agentaudit setup | login | 使用GitHub OAuth登录或手动粘贴API密钥 |
agentaudit status | whoami | 显示当前配置、API密钥和个人统计信息 |
全球旗帜
| 标志 | 描述 |
|---|---|
--json | 将机器可读的JSON输出到stdout |
--quiet / -q | 抑制横幅和装饰输出 |
--no-color | 禁用ANSI颜色(也尊重 NO_COLOR ) 。 |
--model | 覆盖此运行的LLM模型 |
--models | 多模型审计(并行调用、共识比较) |
--verify | 对抗性验证: self (同一型号), cross (不同型号),或 ``。自动启用注册表上传。 |
--no-verify | 跳过验证和注册表上传(仅本地扫描) |
--remote | 使用agentaudit.dev服务器进行扫描(不需要本地LLM密钥) |
--no-upload | 跳过将报告上传到注册表 |
--export | 将审计有效负载导出为降价 |
--debug | 显示解析错误时的原始LLM响应 |
--help / -h | 显示帮助文本 |
-v / --version | 显示版本 |
退出代码
| 代码 | 含义 |
|---|---|
0 | 干净--未检测到任何结果,或查找成功 |
1 | 检测到的结果 |
2 | 错误(克隆失败、网络错误、参数无效) |
______________________________________________________________________
⚖️ 快速扫描与深度审计
快速扫描(scan) | 深度审计(audit) | |
|---|---|---|
| 速度 | 约2秒 | 约30秒 |
| 方法 | 正则表达式模式匹配 | LLM驱动的3遍分析 |
| 需要API密钥 | 否 | 是(Anthropic、OpenAI或OpenRouter) |
| 假阳性 | 更高(正则表达式限制) | 非常低(上下文感知) |
| 发现 | 常见模式(注入、秘密、评估) | 复杂的攻击链、特定于AI的威胁、混淆 |
| 最适合 | 快速分类、CI管道 | 关键包、预生产审查 |
提示: 使用 agentaudit scan --deep 通过扫描命令运行深度审计。
______________________________________________________________________
🔌 MCP服务器
当作为MCP服务器运行时,AgentAudit向您的AI代理公开以下工具:
| 工具 | 说明 |
|---|---|
audit_package | 基于LLM的深度存储库审计 |
check_registry | 在信任注册表中查找包 |
submit_report | 将审计结果上传到注册表 |
discover_servers | 在本地编辑器配置中查找MCP服务器 |
consensus_analysis | 包的跨模型共识视图 |
search_packages | 按名称、ASF-ID或哈希在注册表中搜索包 |
scan_tool_poisoning | 在MCP工具描述中检测工具中毒 |
工作流程
User asks agent to install a package
│
▼
Agent calls check_registry(package_name)
│
┌────┴────┐
│ │
Found Not Found
│ │
▼ ▼
Return Agent calls audit_package(repo_url)
score │
▼
LLM analyzes code (3-pass)
│
▼
Agent calls submit_report(findings)
│
▼
Return findings + risk score______________________________________________________________________
🎯 它检测到什么
核心安全
AI专用
MCP特定
坚持与困惑
______________________________________________________________________
🧠 三通审核的工作原理
深度审计(agentaudit audit)使用结构化的三相LLM分析——不是单次射击提示,而是严格的多遍过程:
| 阶段 | 名称 | 发生了什么 |
|---|---|---|
| 1 | 🔍 理解 | 读取所有文件并构建 包装简介目的、类别、预期行为、信任界限。还没有扫描——目标是了解包裹的内容 *应该* 在寻找它之前先做 *不应该*. |
| 2 | 🎯 检测 | 证据收集 50+检测模式 跨8个类别(AI特定、MCP、持久性、混淆、跨文件相关性)。只记录了事实,还没有严重性判断。 |
| 3 | ⚖️ 分类 | 每一个发现都要经过一个 强制性自检 (5个问题), 可利用性评估,以及 信心门控高/关键发现必须经受住考验 魔鬼代言人 挑战并包含完整 推理链. |
为什么是3次传球? 单程分析是假阳性的首要原因。通过分离理解→ 检测→ 分类:
- 第一阶段防止将核心功能标记为可疑(例如,数据库工具中的SQL执行)
- 第二阶段确保收集的证据没有严重性偏差
- 第三阶段在假阳性到达报告之前发现假阳性
该架构实现了 0%假阳性 在我们的11包测试集上,这一比例低于v2中的42%。
对抗验证通行证(v3.14+)
经过三级审核后 验证通行证 对照实际源代码重新检查每个发现。 上传到注册表时自动启用验证 以确保数据质量。对于仅本地扫描,请使用 --no-verify 跳过它(这也会禁用注册表上传)。
# Verification runs automatically when uploading (default behavior)
agentaudit audit https://github.com/owner/repo
# Explicit verification mode
agentaudit audit https://github.com/owner/repo --verify cross
# Skip verification + upload (local-only, fast)
agentaudit audit https://github.com/owner/repo --no-verify每个发现都要经过一个5点检查表:
- 代码存在 --引用的代码是否确实存在于文件中?
- 上下文准确性 --代码是否按照描述的方式使用?
- 执行模型 --攻击者真的能触发这个吗?
- 严重性校准 --严重程度是否合适?
- 制造检查 --是否存在幻觉般的细节?
判决: verified (确认为真实), demoted (严重程度降低), rejected (去除假阳性)。
为什么上传需要验证? LLM可能会产生不存在的代码幻觉或夸大严重性。如果不进行验证,误报就会进入公共注册表,并不公平地将包标记为不安全。验证通行证会在这些记录成为永久记录之前将其捕获。
模型精度(真实世界数据)
我们对多个LLM进行了基准测试 20款最受欢迎的MCP服务器 (62+份报告):
| 模型 | 前20名发现 | 精度 | 评估 |
|---|---|---|---|
| 克劳德作品4.6 | 0个发现(全部干净) | N/A | 非常保守——是避免误报的理想选择 |
| 双子座2.5闪光灯 | 许多发现 | ~30%严格 | 假阳性率高——不建议用于生产审核 |
关键见解: 模型选择对审计质量有显著影响。我们建议使用Claude Opus 4或Claude Sonnet 4进行生产审核。使用--models运行多个模型并通过以下方式比较结果consensus.
______________________________________________________________________
🔄 CI/CD集成
AgentAudit专为具有适当退出代码和JSON输出的CI管道而设计:
# GitHub Actions example
- name: Scan MCP servers
run: |
npx agentaudit scan https://github.com/org/mcp-server --json --quiet > results.json
# Exit code 1 = findings detected → fail the build# Shell scripting
agentaudit scan https://github.com/owner/repo --json --quiet 2>/dev/null
if [ $? -eq 1 ]; then
echo "Security findings detected!"
exit 1
fiJSON输出示例
# Scan with JSON output
agentaudit scan https://github.com/owner/repo --json{
"slug": "repo",
"url": "https://github.com/owner/repo",
"findings": [
{
"severity": "high",
"title": "Command injection risk",
"file": "src/handler.js",
"line": 42,
"snippet": "exec(`git ${userInput}`)"
}
],
"fileCount": 15,
"duration": "1.8s"
}# Registry lookup with JSON
agentaudit lookup fastmcp --json马上就来:--fail-on标记以设置非零退出的最小严重性阈值(例如。,--fail-on high忽略低/中发现)。
______________________________________________________________________
📊 仪表板和社区
AgentAudit包括一个全屏交互式仪表板和独立的社区命令。
交互式仪表板
agentaudit dashboard # or: agentaudit dash5标签TUI,带键盘导航(←→标签,↑↓ 滚动,1-5跳,q退出)。 概述选项卡包括 交互式快速操作 --直接从仪表板选择并启动审核、共识视图或远程扫描:
| 选项卡 | 内容 |
|---|---|
| \[1\] 概述 | 您的个人资料+注册表统计数据+交互式快速操作(按a/v/r/c或Enter) |
| \[2\] 排行榜 | 奖牌排名和柱状图的顶级贡献者 |
| \[3\] 基准 | LLM模型审计绩效比较 |
| \[4\] 活动 | 您最近的审计和发现 |
| \[5\] 搜索 | 交互式包裹搜索(键入搜索,输入提交) |
独立命令
所有社区命令都可以在没有仪表板的情况下工作(管道友好,支持 --json):
agentaudit leaderboard # Top contributors
agentaudit leaderboard --tab monthly --json # Monthly rankings as JSON
agentaudit benchmark # Model comparison
agentaudit activity # Your recent audits & findings
agentaudit search fastmcp # Search registry by name/ASF-ID
agentaudit search fastmcp --json # Machine-readable search results______________________________________________________________________
⚙️ 配置
凭证
AgentAudit将凭据存储在 ~/.config/agentaudit/credentials.json (或 $XDG_CONFIG_HOME/agentaudit/credentials.json).
跑 agentaudit setup 使用GitHub登录或粘贴API密钥,或通过环境设置:
export AGENTAUDIT_API_KEY=asf_your_key_here法学硕士提供者(支持13个)
AgentAudit支持13家LLM提供商进行深度审计。设置一个API密钥-CLI自动检测它。使用 agentaudit model 以交互方式选择提供者+模型,或 agentaudit status 检查您的设置。
| 变量 | 提供者 | 默认模型 |
|---|---|---|
ANTHROPIC_API_KEY | 人类学(克劳德) | claude-sonnet-4-20250514 |
GEMINI_API_KEY | 谷歌(双子座) | gemini-2.5-flash |
OPENAI_API_KEY | OpenAI(GPT-4o) | gpt-4o |
DEEPSEEK_API_KEY | DeepSeek | deepseek-chat |
MISTRAL_API_KEY | 米斯特拉尔 | mistral-large-latest |
GROQ_API_KEY | Groq | llama-3.3-70b-versatile |
XAI_API_KEY | xAI(格罗克) | grok-3 |
TOGETHER_API_KEY | 一起AI | Llama-3.3-70B-Instruct-Turbo |
FIREWORKS_API_KEY | 烟花AI | llama-v3p3-70b-instruct |
CEREBRAS_API_KEY | 大脑 | llama-3.3-70b |
ZAI_API_KEY | 智普AI(GLM) | glm-4.7 |
OPENROUTER_API_KEY | OpenRouter | anthropic/claude-sonnet-4 |
其他环境变量
| 变量 | 描述 |
|---|---|
AGENTAUDIT_API_KEY | 用于注册表上载的API密钥(或使用 agentaudit setup) |
AGENTAUDIT_MODEL | 覆盖LLM模型(与 --model 旗帜) |
NO_COLOR | 禁用ANSI颜色(no-color.org) |
提供商优先级: 集preferred_provider通过agentaudit model,或者CLI选择第一个可用密钥。每次运行覆盖--model.
______________________________________________________________________
📦 需求
- Node.js ≥ 18.0.0
- Git (用于在扫描/审核期间克隆存储库)
______________________________________________________________________
❓ 常见问题解答
如何设置AgentAudit?
npm install -g agentaudit
agentaudit setup或者在不安装的情况下使用: npx agentaudit
我需要API密钥吗?
- 快速扫描 (
scan):不需要API密钥-使用regex在本地运行 - 深度审计 (
audit):需要LLM API密钥(请参见下文) - 注册表查找 (
lookup):阅读无需钥匙;上传报告所需的密钥 - MCP服务器:不需要额外的键--使用宿主编辑器的LLM
设置LLM密钥以进行深度审核
这 audit 命令支持 13名法学硕士提供者.设置一个API密钥,AgentAudit自动检测该密钥:
# Set any one of these (Anthropic recommended)
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export GEMINI_API_KEY=...
export DEEPSEEK_API_KEY=...
# ... or any of the 13 supported providers (see Configuration section)交互式设置:
agentaudit model # 2-step menu: pick provider → pick model
agentaudit status # check which keys are set + current config每次运行覆盖:
agentaudit audit https://github.com/owner/repo --model gpt-4o故障排除: 如果你看到 API error: Incorrect API key,请仔细检查您的密钥是否有效,是否有积分。使用 --debug 查看API的完整响应。
哪些数据被发送到外部?
- 注册表查找:包名/slug发送到
agentaudit.dev检查现有审计 - 报告上传:审核结果上传到公共注册表(需要API密钥)
- 深度审计:源代码被发送到Anthropic或OpenAI进行LLM分析
- 快速扫描:一切都是本地的,没有数据离开你的机器
我可以离线使用它吗?
快速扫描(agentaudit scan)克隆后完全脱机工作。注册表查找和深度审计需要网络访问。
我可以在没有CLI的情况下将其用作MCP服务器吗?
对! npx agentaudit 当编辑器调用时,启动MCP服务器。CLI和MCP服务器是同一个包——行为取决于它的调用方式。
如何 discover 知道我使用哪些编辑器吗?
它检查Claude Desktop、Cursor、VS Code和Windsurf的标准配置文件位置。它还检查项目级别的当前工作目录 .cursor/mcp.json 和 .vscode/mcp.json.
______________________________________________________________________
🔗 相关
| 项目 | 描述 | |
|---|---|---|
| 🌐 | agentaudit.dev | 信任注册表--浏览包、调查结果、排行榜 |
| 🛡️ | 代理审计技能 | 代理技能——为Claude Code、Cursor、Windsurf预装安全门 |
| ⚡ | GitHub操作--CI/CD安全扫描 | |
| 📚 | 代理审计cli | 此仓库--CLI+MCP服务器源代码 |
| 🐛 | 报告问题 | Bug报告和功能请求 |
______________________________________________________________________
📄 许可证
AGPL-3.0 --免费开源使用。商业许可证可用于专有集成。
______________________________________________________________________
保护您的AI堆栈。先扫描再信任。
