代理扫描
AI代理安全姿态扫描器 --枚举机器上的所有AI编码代理,并映射它们的聚合权限表面。
开发人员同时运行3-5个AI代理。没有人审核汇总。每个代理都有不同的配置文件、MCP服务器、shell访问、文件系统作用域和凭据暴露。 agentscan 将它们全部映射到一个命令中。
它扫描什么
| 代理 | 配置位置 | 它检查什么 |
|---|---|---|
| 克劳德桌面 | ~/Library/Application Support/Claude/ | MCP服务器,配置中的秘密 |
| 克劳德代码 | ~/.claude/, ~/.claude.json,项目 .claude/ | 权限、允许的工具、危险标志、MCP |
| 光标 | ~/.cursor/, ~/Library/.../Cursor/ | MCP服务器, .cursorrules 秘密 |
| VS Code | ~/Library/.../Code/User/ | Copilot、Cline、Continue、Roo Code、MCP |
| 帆板运动 | ~/Library/.../Windsurf/, ~/.codeium/ | MCP服务器,设置 |
| 泽德 | ~/.config/zed/ | 配置、助手设置中的API密钥 |
| Codex CLI | ~/.codex/ | 审批方式、指令秘密 |
| 教唆者 | ~/.aider.* | 配置机密、.env文件 |
| Moltbot/OpenClaw | ~/clawd/, ~/.config/moltbot/ | AGENTS.md、sudo用法、正在运行的进程 |
它发现了什么
每位代理人
- 🔑 硬编码的秘密 (配置文件中的API密钥、令牌、密码)
- 🛡️ MCP服务器风险 (shell执行、危险命令、未经审查的包、文件系统作用域)
- ⚡ 危险权限 (永久允许的工具,
--dangerously-skip-permissions,全自动模式) - 📂 文件系统暴露 (系统目录访问,敏感路径挂载)
- 🔓 凭证风险 (传递给MCP服务器的敏感环境变量)
交叉代理
- 📊 药剂密度 (代理太多=攻击面太多)
- 🔗 共享MCP服务器 (多个代理中的同一服务器会增加风险)
- 🐚 壳体进入浓度 (多个带外壳的药剂=高爆炸半径)
- 📈 MCP总表面积 (总权限足迹)
快速开始
# Scan everything
python3 agentscan.py
# JSON output
python3 agentscan.py --format json
# Scan specific agents
python3 agentscan.py --agents "claude code" cursor
# CI mode (exit 1 if grade below C)
python3 agentscan.py --ci --threshold C输出示例
agentscan v0.1.0 — AI Agent Security Posture Scanner
Platform: macos | Host: dev-machine.local
SUMMARY
Agents installed: 4 / 9
MCP servers: 7
Findings: 12
Grade: D (risk score: 38)
════════════════════════════════════════════════════════════
Claude Desktop
Config files: 1
MCP servers: 3
Findings: 4
MCP Servers:
• filesystem ⚠
Command: npx @modelcontextprotocol/server-filesystem /
↳ Full filesystem access — check allowed paths
• shell ⚠
Command: npx @anthropic/mcp-shell
↳ Direct shell execution — highest risk
• postgres ⚠
Command: npx @modelcontextprotocol/server-postgres
↳ Database access — production risk
↳ Exposes sensitive env vars: DATABASE_URL
Findings:
[CRITICAL] Secret in config: OpenAI API key
Found OpenAI API key pattern in claude_desktop_config.json
→ Move secrets to environment variables or a credential vault
[HIGH] MCP server 'shell': Direct shell execution
Direct shell execution — highest risk
→ Review MCP server permissions and scope access minimally
...
════════════════════════════════════════════════════════════
CROSS-AGENT FINDINGS
[HIGH] Multiple agents with shell access: 2
Agents with shell: Claude Desktop, Cursor
→ Limit shell access to one agent. Use MCP tools for others.
[MEDIUM] MCP server 'filesystem' shared across agents
Configured in: Claude Desktop, Cursor
→ Use separate MCP server instances per agent where possible评分
| 等级 | 风险评分 | 含义 |
|---|---|---|
| A. | 0 | 干净--没有发现 |
| B | 1-5 | 小问题(仅信息/低发现) |
| C | 6-15 | 中等风险(一些中等发现) |
| D | 16-30 | 高风险(高严重性发现) |
| F | 31+ | 重大风险(秘密暴露,外壳无处不在) |
严重性权重:严重性=25,高=10,中=3,低=1,信息=0
CI集成
# GitHub Actions
- name: Agent Security Audit
run: python3 agentscan.py --ci --threshold C --format json > agentscan.json# Pre-commit hook
python3 agentscan.py --ci --threshold B --no-color检测到秘密模式
| 图案 | 描述 |
|---|---|
sk-[a-zA-Z0-9]{48} | OpenAI API密钥 |
sk-proj-* | OpenAI项目密钥 |
sk-ant-* | 无烟煤API键 |
ghp_* | GitHub PAT(经典版) |
github_pat_* | GitHub PAT(细粒度) |
AKIA* | AWS访问密钥 |
xox[bpors]-* | Slack令牌 |
glpat-* | GitLab PAT |
SG.* SendGrid API 密钥 |
MCP风险评估
扫描程序对每个MCP服务器进行以下评估:
- 指挥风险 --服务器是否通过危险的命令(bash、sh、docker)启动?
- 包装风险 --它是通过npx发布的未经审查的第三方npm包吗?
- 已知服务器风险 --它是一种以广泛访问(文件系统、shell、数据库)而闻名的服务器类型吗?
- 凭证风险 --服务器是否接收敏感的环境变量?
- 标记风险 --是否使用了危险标志(--没有沙箱,--危险-\*)?
需求
- Python 3.9+
- 零依赖性(仅限stdlib)
- 支持macOS和Linux
- 单个文件(
agentscan.py)
局限性
- 仅基于配置的扫描 --agentscan读取配置文件,而不是运行时状态
- 无网络监控 --不跟踪代理在运行时实际做了什么
- 配置位置假设 --可能缺少自定义配置路径
- 扩展检测 --VS代码扩展检测依赖于已知的目录名
- 凭证模式 --基于正则表达式,可能会遗漏混淆或旋转的秘密
对于运行时监控,请与 安全的开爪图案.
相关
许可证
麻省 理工© 2026 克里斯 金默尔
