LuciferForge/mcp-security-audit

GitHub: LuciferForge/mcp-security-audit

一款 MCP 服务器安全审计工具,通过枚举工具、扫描注入模式、分类风险等级并生成评分报告,帮助开发者在部署前发现潜在安全漏洞。

Stars: 2 | Forks: 0

# mcp-security-audit [![PyPI version](https://img.shields.io/pypi/v/mcp-security-audit)](https://pypi.org/project/mcp-security-audit/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/) **MCP 服务器的安全审计工具。** 连接到任何 MCP 服务器,枚举其 tools/resources/prompts,扫描注入模式,对风险等级进行分类,并生成评分报告(0-100 分,等级 A-F)。 可作为 CLI 工具 (`mcp-audit`) 或 MCP 服务器本身 (`mcp-security-audit`) 使用。 **为何重要:** 目前公共生态系统中已有 [16,000+ 个 MCP 服务器](https://protodex.io) —— 其中几乎没有经过安全审计。每一个都在运行时拥有对 shell、文件系统或网络的工具访问权限,而单个包含注入内容的工具描述就能劫持加载它的 agent。此工具能在攻击者之前发现这些漏洞。 ## 安装 ``` pip install mcp-security-audit ``` ## CLI 用法 ### 文本报告 ``` mcp-audit scan --server "python -m my_mcp_server" ``` ### JSON 报告 ``` mcp-audit scan-json --server "python -m my_mcp_server" --output report.json ``` ### 包含实时注入测试 ``` mcp-audit scan --server "python -m my_mcp_server" --live-tests ``` ### CI/CD 等级 A/B 返回退出代码 0,C/D/F 返回 1: ``` mcp-audit scan --server "uvx some-server" || echo "Security audit failed" ``` ## MCP 服务器模式 作为 MCP 服务器使用,以便 AI 助手可以审计其他服务器: ### Claude Code ``` claude mcp add mcp-security-audit -- uvx mcp-security-audit ``` ### 手动 ``` { "mcpServers": { "mcp-security-audit": { "command": "uvx", "args": ["mcp-security-audit"] } } } ``` ### 暴露的 Tools | Tool | 功能描述 | |---|---| | `audit_scan` | 完整的安全审计与文本报告 | | `audit_quick_scan` | 快速扫描 — 评分、等级、核心发现 | | `audit_classify` | 对单个 tool 的风险等级进行分类 | | `audit_check_text` | 扫描文本中的注入模式 | ## 检查内容 1. **Tool 风险分类** — 将每个 tool 分类为 SHELL / FILE / DATABASE / NETWORK / SAFE 2. **注入模式扫描** — 扫描 tool 和 prompt 的描述,检测跨越 9 个类别的 75 种注入模式 3. **Resource URI 分析** — 标记敏感路径(如 .env、.ssh、credentials 等) 4. **高风险比例** — 如果超过 50% 的 tool 属于 FILE 或 SHELL 级别,则发出警告 5. **未记录的 tool** — 标记缺少描述的 tool 6. **攻击面** — 当存在 20 个以上的 tool(大型)或 50 个以上的 tool(超大型)时发出警告 7. **实时注入测试**(可选) — 向字符串参数的 tool 发送 payload ## 评分 初始分为 100,根据发现的问题进行扣分: | 严重程度 | 扣分 | |---|---| | CRITICAL | -25 | | HIGH | -15 | | MEDIUM | -8 | | LOW | -3 | 加分项:每个有文档记录的 tool 加 1 分(最高加 5 分)。 等级:A (90+)、B (75+)、C (60+)、D (40+)、F (<40) ## 示例输出 ``` ============================================================ MCP SECURITY AUDIT REPORT ============================================================ Server: python -m agent_safety_mcp.server Tools: 13 Score: 92/100 (Grade A) ------------------------------------------------------------ TOOL CLASSIFICATION ------------------------------------------------------------ Tool Risk Matched cost_guard_configure SAFE - cost_guard_status SAFE - injection_scan SAFE - trace_save FILE !!save, file ... ``` ## 依赖项 - [mcp](https://pypi.org/project/mcp/) — MCP 协议 SDK - [ai-injection-guard](https://pypi.org/project/ai-injection-guard/) — 涵盖 9 个类别的 75 种 prompt 注入检测模式 [LuciferForge](https://github.com/LuciferForge) AI Agent 基础设施栈的一部分。 ## License MIT
标签:DLL 劫持, MCP服务器, Python, 大语言模型, 无后门, 逆向工具