echo-lumen/mcp-security-scan
GitHub: echo-lumen/mcp-security-scan
首个能动态连接运行中 MCP 服务器的开源安全扫描器,依据 OWASP MCP Top 10 标准进行安全审计。
Stars: 0 | Forks: 0
# mcp-security-scan
针对 [OWASP MCP Top 10](https://owasp.org/www-project-mcp-top-10/) 对 MCP 服务器进行审计。唯一**真正连接**到运行中服务器的开源扫描器。
## 为什么开发这个工具
生态系统中存在 8,500 多个 MCP 服务器。其中 [38% 完全缺乏身份验证](https://www.practical-devsecops.com/mcp-security-vulnerabilities/)。在 60 天内已提交了 30 个 CVE。现有工具要么回连到专有 API(如 Snyk),要么仅分析静态配置文件而从未连接到服务器。
该工具通过标准协议连接到您的 MCP 服务器,检索实际的工具定义,并扫描其中的安全问题。所有操作均在本地运行。无需 API 密钥。数据不会离开您的设备。
## 检查内容
| 类别 | 检查项 | 模式 |
|----------|-------|------|
| **MCP01** Token Mismanagement | 参数、环境变量、URL 中的凭据 | Static + Dynamic |
| **MCP02** Privilege Escalation | 危险的工具组合(执行 + 网络,文件 + 网络) | Dynamic |
| **MCP03** Tool Poisoning | 描述中的隐藏指令、名称遮蔽 | Dynamic |
| **MCP04** Supply Chain | 未锁定版本的包、自动安装标志 | Static |
| **MCP05** Command Injection | Shell 执行模式、可注入参数 | Dynamic |
| **MCP06** Prompt Injection | 接受类 Prompt 内容的参数 | Dynamic |
| **MCP07** Authorization Failures | 破坏性工具、无限制的访问范围 | Dynamic |
| **MCP08** Insufficient Telemetry | 缺失日志记录能力 | Dynamic |
| **MCP10** Context Oversharing | 暴露给 LLM 上下文的敏感参数 | Dynamic |
**Static checks** 分析您的 `mcp.json` 配置,而无需启动服务器。
**Dynamic checks** 连接到运行中的服务器,检索工具定义并进行分析。
## 安装
```
pip install -e .
```
需要 Python 3.10+ 和 `mcp` SDK。
## 用法
### 扫描配置文件(完整动态扫描)
```
mcp-scan --config ~/.claude/mcp.json
```
### 扫描单个服务器
```
mcp-scan --command npx @modelcontextprotocol/server-filesystem /tmp
```
### 自动发现并扫描所有配置
```
mcp-scan --auto
```
### 仅静态扫描(快速,不连接服务器)
```
mcp-scan --static ~/.claude/mcp.json
```
### JSON 输出(用于 CI/CD)
```
mcp-scan --config mcp.json --format json
```
## 退出码
| 代码 | 含义 |
|------|---------|
| 0 | 无高/严重发现 |
| 1 | 高危发现 |
| 2 | 严重发现 |
在 CI 中使用:`mcp-scan --config mcp.json --format json || echo "Security issues found"`
## 示例输出
```
============================================================
MCP Security Scan Report
OWASP MCP Top 10 Audit
============================================================
Server: my-filesystem-server
Name: filesystem
Version: 1.0.0
Protocol: 2025-03-26
Tools: 5
Tool list:
- read_file: Read complete contents of a file
- write_file: Create or overwrite a file
- list_directory: List directory contents
- delete_file: Delete a file from the filesystem
- execute_command: Execute a shell command
Findings (4):
[HIGH] Server has both code execution and filesystem access
Category: MCP02: Privilege Escalation
Detail: Combining execution and filesystem tools enables arbitrary file manipulation
Fix: Sandbox execution tools. Restrict filesystem access paths.
[HIGH] Command injection risk: Shell metacharacters in string
Category: MCP05: Command Injection
Tool: execute_command
Detail: Tool 'execute_command' description suggests shell execution
Fix: Avoid passing user input to shell commands.
[MEDIUM] Destructive tool detected
Category: MCP07: Authorization Failures
Tool: delete_file
Fix: Mark destructive tools with destructiveHint: true.
[MEDIUM] Unpinned npm package: @modelcontextprotocol/server-filesystem
Category: MCP04: Supply Chain
Fix: Pin to a specific version: e.g., package@1.2.3
------------------------------------------------------------
SUMMARY
Servers scanned: 1
Total findings: 4
HIGH: 2
MEDIUM: 2
RESULT: HIGH severity issues found. Review and remediate.
```
## 与现有工具的区别
| 工具 | 动态 | 开源 | 仅本地 |
|------|:-------:|:----------:|:----------:|
| **mcp-security-scan** | 是 | 是 | 是 |
| Snyk Agent Scan | 是 | 部分* | 否(回传数据) |
| MCPSec | 否(静态) | 是 | 是 |
| mcp-security-scan (cc-fuyu) | 否(静态) | 是 | 是 |
*Snyk 的扫描器是 Apache-2.0 许可,但需要专有 API 进行分析。
## 贡献
发现了应该存在的检查项?提交一个 PR。每个检查项应:
- 映射到一个 OWASP MCP Top 10 类别
- 具有明确的严重性判定逻辑
- 包含修复指导
- 适用于真实的服务器输出,而不仅仅是测试固件
## 许可证
MIT
标签:AI安全, Chat Copilot, DNS 反向解析, MCP安全, OWASP Top 10, Python, 云安全监控, 凭据泄露检测, 加密, 协议分析, 命令注入检测, 工具投毒检测, 开源安全工具, 无后门, 权限提升, 模型上下文协议, 漏洞扫描器, 网络安全审计, 逆向工具, 逆向工程平台, 静态分析