麦克普努克
MCP红队和安全扫描仪
安全扫描仪 模型上下文协议 服务器。联合 静态元数据分析 和 积极行为 探测 --连接到MCP服务器、枚举工具/资源/提示, 调用具有安全有效载荷的工具,并分析返回的内容。
适用于标准MCP(SSE、流式HTTP), 本地stdio服务器 (npx, python等)、非标准工具服务器(POST /execute),以及 Kubernetes内部MCP部署。
与...一起使用 DVMCP 用于培训,或指向dev/station/prod中的任何MCP服务器。
看 更改日志.md 了解最近的变化和计划的工作。
______________________________________________________________________
安装
快速入门(推荐):
git clone https://github.com/babywyrm/mcpnuke.git && cd mcpnuke
./quickstart.sh这创建了一个 .venv,安装所有附加组件(dev、ai、k8s),运行测试,以及 打印使用。之后, ./scan 和 uv run mcpnuke 只是工作——不 需要激活。
uv(手动):
uv sync --all-extras
uv run mcpnuke --help不 source .venv/bin/activate 需要-- uv run 自动查找项目venv。
可选附加功能: dev (测试/起毛), ai (克劳德分析), k8s (Kubernetes检查), all (一切)。
pip(手动):
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[all,dev]"来自PyPI (即将推出):
uv pip install 'mcpnuke[all]'验证您的安装:
mcpnuke --doctor______________________________________________________________________
快速开始
新来的mcpnuke? 试试 DVMCP演练 -- 扫描10个易受攻击的MCP服务器并解释每个发现的动手指南。 或者跑 ./walkthrough/demo.sh 对于全自动版本。 用于跨camazotz、DVMCP、确定性基准测试和 基岩变化,见 QUICKSTART.md.
# Single target
./scan --targets http://localhost:2266
# DVMCP challenges 1–10
./scan --port-range localhost:9001-9010 --verbose
# Authenticated endpoint (JWT, PAT, etc.)
./scan --targets https://api.githubcopilot.com/mcp/ --auth-token ghp_xxx
# OIDC auto-token (Keycloak, etc.)
./scan --targets http://localhost:9090/mcp \
--oidc-url http://keycloak:8080/realms/myapp \
--client-id myapp --client-secret SECRET
# OIDC with explicit scope, extra headers, and TLS verification
./scan --targets https://target.example/mcp \
--oidc-url https://auth.example/realms/agentic \
--client-id scanner --client-secret SECRET \
--oidc-scope "mcp.read mcp.invoke" \
--header "X-Tenant: blue" \
--header "X-Agent-Flow: planner" \
--tls-verify
# Optional: DPoP + token introspection + JWKS metadata checks
./scan --targets https://target.example/mcp \
--auth-token "$ACCESS_TOKEN" \
--dpop-proof "$DPOP_PROOF_JWT" \
--token-introspect-url "https://auth.example/oauth2/introspect" \
--token-introspect-client-id scanner \
--token-introspect-client-secret SECRET \
--jwks-url "https://auth.example/.well-known/jwks.json" \
--tls-verify \
--json auth-flow-report.json
# JSON report for CI
./scan --port-range localhost:9001-9010 --json report.json
# Differential scan (compare to baseline)
./scan --targets http://localhost:9001 --baseline baseline.json
# Scan a local MCP server via stdin/stdout (no proxy needed)
./scan --stdio 'npx -y @modelcontextprotocol/server-everything'
# Fast scan (~2min vs ~30min) — samples top 5 security-relevant tools, skips heavy probes
./scan --targets http://localhost:9090 --fast --verbose
# Grouped findings (compact report)
./scan --targets http://localhost:9090 --group-findings
# Parallel deep probes (faster behavioral phase)
./scan --targets http://localhost:9090 --probe-workers 4
# AI-powered analysis (requires ANTHROPIC_API_KEY)
./scan --targets http://localhost:9002/sse --claude --verbose
./scan --targets http://localhost:9002/sse --claude --claude-model claude-opus-4-20250514
./scan --targets http://localhost:9002/sse --claude --claude-max-tools 25 --claude-phase2-workers 3
# AI-powered analysis via AWS Bedrock Claude (optional)
./scan --targets http://localhost:9002/sse --claude --bedrock --bedrock-region us-east-1
# Run tests
uv run pytest tests/ -v全部 ./scan 命令也可以作为 uv run mcpnuke (无需激活), mcpnuke (激活venv),或 .venv/bin/mcpnuke.
当 --auth-token 看起来像一个JWT,mcpnuke解码它(没有签名 验证),并在JSON输出中包含安全声明摘要 auth_context.jwt_claims_summary 以帮助验证代理身份验证连接。 如果已配置,还包括令牌自检和JWKS获取摘要 在...之下 auth_context 而不会影响禁用时的扫描行为。
退出代码: 0 --无发现(干净); 1 --报告的调查结果; 2 --扫描 错误(连接失败、参数无效等)。使用 1 对比 2 在CI 区分“发现漏洞”和“扫描失败”
______________________________________________________________________
运作原理
1. CONNECT Detect transport (SSE, Streamable HTTP, stdio, or custom tool server)
2. ENUMERATE initialize → tools/list → resources/list → prompts/list
(or probe tool names for non-MCP /execute APIs)
3. STATIC CHECKS Pattern-match metadata (names, descriptions, schemas)
4. PROBE Call tools with safe payloads, read resources
5. ANALYZE Scan responses for injection, exfil, leakage, drift
6. AGGREGATE Detect attack chains across findings
7. REPORT Console table (or --group-findings) + optional JSON扫描阶段
扫描仪按照深思熟虑的顺序运行检查:
| 阶段 | 检查 | 发生了什么 |
|---|---|---|
| 静态 | prompt_injection、tool_poising、excessive_permissions、token_theft、codeexecution、remote_access、schema_frisks、rate_limit、prompt_leakage、supply_chain、tool_shadow、webhook_persistence、credential_in_schema、config_forting、exfil_flow | 工具名称、描述、模式的模式匹配。枚举之外没有服务器交互。 |
| 行为 | rug_pull、indirect_injection、protocol_robustness | 轻量级交互:重新列出工具、读取资源、发送无效方法。 |
| 深探头 | deep_rug_pull、tool_response_injection、input_sanitization、error_leakage、temporal_consistency、resource_poising、responde_credentials、state_mutation、notification_optist | 使用安全有效载荷的主动工具调用。分析威胁的应对措施。 |
| 运输 | sse_security | CORS,未经身份验证的sse,跨源POST。 |
| 聚合 | 多向量、攻击链 | 交叉引用所有先前的发现来检测复合威胁。 |
| 人工智能 (可选) | llm_tool_analysis、llm_response_analysics、llm_chain_reasoning | Claude读取定义、工具输出和所有发现,以识别微妙的风险和多步攻击链。需要 --claude. |
______________________________________________________________________
安全检查参考
静态检查(仅元数据)
| 检查 | 严重性 | 它检测到什么 |
|---|---|---|
prompt_injection | 关键 | 工具/资源/提示描述中的注入有效载荷 |
tool_poisoning | 关键 | 隐藏指令,工具描述中不可见的Unicode |
excessive_permissions | 关键-中等 | 危险功能(外壳、文件系统、网络、数据库、云) |
code_execution | CRITICAL–HIGH | 带有exec/eval/shell参数或描述的工具 |
remote_access | 关键–高 | 反向炮弹、C2信标、端口转发、数据泄露 |
token_theft | CRITICAL–HIGH | 接受或转发凭据作为参数的工具 |
supply_chain | 关键 | 从用户控制的URL动态安装软件包 |
schema_risk | 临界–中等 | 命令参数、无界字符串、自由对象 |
tool_shadowing | 高–中 | 与常用工具或其他服务器冲突的工具名称 |
prompt_leakage | HIGH | 可能回显、记录或公开内部提示的工具 |
rate_limit | MEDIUM | 建议无限制/无限制使用的描述 |
webhook_persistence | 高–中 | 回调/webhook参数或工具名称,可实现持久重新注入 |
credential_in_schema | CRITICAL–HIGH | 工具架构中的硬编码凭据(API密钥、JWT、连接字符串) |
config_tampering | HIGH | 可以修改代理配置、系统提示或工具注册表的工具 |
exfil_flow | 关键 | 从敏感源工具到通信/网络接收器的数据流 |
jwt_algorithm | 临界-高 alg:none (签名绕过)或对称HMAC算法 | |
jwt_issuer | 中等 | JWT缺失 iss (发行人)索赔 |
jwt_audience | 中等 | JWT缺失 aud (观众)声明——支持跨服务回放 |
jwt_audience_target_match | 高 | 1号车道/MCP-T04。解码承载令牌、从目标URL(完整URL,scheme://netloc、host、host:port),并在以下情况下标记 aud 不与任何预期的形式相交。捕获跨工具令牌重播,其中为服务a颁发的令牌被服务B静默接受(受众验证禁用或受信任的aud重叠)。 |
jwt_cross_role_replay | 高 | 1号车道/MCP-T04。倒像 scope / role / roles 声称;当所有值都是read类(read、viewer、list、get等),但服务器仍然通过以下方式向令牌公开write/admin/delete工具时 tools/list,标志在同一OIDC领域中破坏了角色隔离。静态检查——不调用写入工具。 |
jwt_token_id | 低 | JWT缺失 jti --无法进行重播检测 |
jwt_ttl | 高-中 | JWT无 exp 或TTL超过阈值(默认4h) |
jwt_weak_key | CRITICAL | 使用已知的弱/默认HMAC密钥签名的JWT |
行为检查(主动服务器交互)
| 检查 | 严重性 | 它检测到什么 |
|---|---|---|
rug_pull | 临界-高 | 工具列表在两个之间变化 tools/list 电话 |
deep_rug_pull | 关键 | 工具列表/模式更改 调用工具后 --捕捉状态依赖的地毯拉扯、注射模式漂移(清洁→ N次通话后中毒) |
tool_response_injection | 关键–高 | 工具中注入有效载荷、提取URL、隐藏内容、不可见的Unicode或base64编码攻击 回应 |
cross_tool_manipulation | HIGH | 指示LLM调用其他工具的工具输出 |
input_sanitization | CRITICAL–HIGH | 路径遍历、命令注入、模板注入、SQL注入探测未经消毒。 LLM了解SSTI: 确认的发动机指纹(Jinja2/Mako/ERB/EL)仍然至关重要;LLM评估的数学风格模板探针(例如。 {{7*7}} → 49)降级为MEDIUM,因此LLM支持的MCP服务器不会被错误标记为代码SSTI。 |
error_leakage | HIGH–MEDIUM | 错误响应中的堆栈跟踪、内部路径、连接字符串或秘密 |
temporal_consistency | 关键-中等 | 不断升级的注入、极其不一致的响应或重复相同呼叫中的新威胁 |
resource_poisoning | 关键–高 | Base64编码注入、数据URI、隐写Unicode、CSS隐藏HTML或资源内容中的markdown图像泄露 |
state_mutation | 高–中 | 工具调用后出现、消失或更改内容的资源 |
notification_abuse | 关键-中等 | 未经请求 sampling/createMessage, roots/list,或其他服务器发起的请求 |
indirect_injection | 临界-高 | 资源含量中的注入/中毒模式;利用嵌入式注入有效载荷探测内容处理工具 |
active_prompt_injection | CRITICAL | 将注入有效载荷作为工具输入发送——检测指令遵循、系统提示泄漏和角色覆盖 |
response_credentials | CRITICAL–HIGH | 工具响应中的凭据(API密钥、密码、私钥、连接字符串) |
运输和骨料检查
| 检查 | 严重性 | 它检测到什么 |
|---|---|---|
auth | HIGH | 接受未经身份验证的MCP/工具服务器初始化 |
sse_security | 高–中 | 未经身份验证的SSE流、CORS配置错误、跨源POST |
multi_vector | 关键 | 一台服务器上有2个以上危险漏洞类别处于活动状态 |
attack_chain | 关键 | 关联的漏洞对(例如。 input_sanitization → code_execution) |
______________________________________________________________________
行为探究方法论
深探头检查 调用目标服务器上的工具 使用安全, 非破坏性有效载荷。其工作原理如下:
安全参数生成
对于每种工具,扫描仪都会读取 inputSchema 并产生最小 使用上下文感知安全值的参数:
| 参数模式 | 安全值 |
|---|---|
path, file, dir | /tmp/mcp_probe_MCP_PROBE_8f4c2a |
command, exec | echo hello |
expression, code | 1+1 |
url, endpoint | http://example.com/test |
username, name | probe_user |
password, token | MCP_PROBE_8f4c2a (金丝雀) |
| 枚举参数 | 第一个枚举值 |
| 其他一切 | test |
仅 必需的 参数已填写。跳过可选参数 尽量减少副作用。
注射探头
对于 input_sanitization,扫描仪根据以下内容发送目标探头 参数语义:
| 参数类型 | 探头示例 |
|---|---|
| 文件/路径参数 | ../../../tmp/MCP_PROBE_8f4c2a,路径空字节 |
| 命令参数 | test; echo MCP_PROBE_8f4c2a,管道/回扣变体 |
| 查询/SQL参数 | ' OR '1'='1, UNION SELECT |
| 其他字符串 | {{7*7}}, ${7*7},ERB/Jinja模板 |
金丝雀线 MCP_PROBE_8f4c2a 嵌入探头中。如果出现 在响应中,该工具反映了未经净化的输入。
响应缓存
当 tool_response_injection 调用工具时,响应将缓存在 probe_opts["_response_cache"]下游检查,如 response_credentials 重用缓存,而不是重新调用相同的工具,消除冗余 呼叫和减少扫描时间。
响应分析
扫描每个工具响应以查找:
- 注射有效载荷 --“忽略前面的指令”、角色替代、系统提示标记
- 语义注入 --模式切换、保密指令、凭证请求、XML/分隔符工具调用注入
- 过滤URL --webhook、ngrok、burp、requestbin、pipedram、interaction
- 隐藏的内容 --HTML评论, `
阻碍,` 标签 - 不可见Unicode --零宽度字符、bidi覆盖、不可见格式化程序
- Base64编码攻击 --对注射模式进行解码和重新扫描
- 交叉工具参考 --“调用工具X”,“调用函数Y”
- LLM分类 (与
--claude)--向Claude发送了模糊的响应,用于恶意/良性分类
______________________________________________________________________
身份识别车道和交通工具
mcpnuke用两个生态系统共享维度标记每个车道范围的发现 来源于代理身份身份流框架,并被冻结 ADR 0001——五运输分类法:
身份识别车道 (the *谁* --请求发起者):
| 车道 | 蛞蝓 | 描述 |
|---|---|---|
| 1 | human-direct | 人类直接向MCP服务器进行身份验证 |
| 2 | delegated | 人类→ 代理令牌交换(代表OAuth) |
| 3 | machine | 工作负载标识(SPIFFE、SA令牌、机器人证书) |
| 4 | chain | 代理商→ 代理人/连锁委托 |
| 5 | anonymous | 预认证或未认证表面 |
运输 (the *怎么* --电线/工艺表面,代码A至E ADR 0001):
| 代码 | 名称 | 备注 |
|---|---|---|
| A | MCP JSON-RPC | 此扫描器的大部分协议都是直接执行的 |
| B | 直连API | REST/gRPC/GraphQL代理在MCP外部调用 |
| C | 进程内SDK/库 | Python导入、进程内函数调用 |
| D | 子进程/本机二进制 | 代理生成 kubectl, terraform等等。;凭证跨越分叉边界 |
| E | 本地LLM函数调用 | OpenAI工具,Anthropic tool_use,Gemini函数调用——不涉及MCP线 |
Finding数据类携带 lane: int | None 和 transport: str | None; --by-lane 按车道分组, --coverage-report 与卡马佐茨相交 schema-v1车道语料库。非通道范围的发现(速率限制、TLS 卫生,通用HTTP表面)保持 lane=None 并按以下方式报告 “未分类。”
运输D和E目前出现在分类学和--by-lane用于卡马佐茨侧面覆盖跟踪的输出;在mcpnuke自己的检查 排放,车道标记的发现主要是运输A(MCP JSON-RPC),因为这是mcpnuke说话的线路。D/E覆盖范围显示 up via--coverage-report对抗正在练习的卡马佐茨靶子 这些表面。
______________________________________________________________________
CLI 参考
./scan [OPTIONS]
Target Selection:
--targets URL [URL ...] One or more MCP target URLs
--port-range HOST:START-END Scan a port range (e.g. localhost:9001-9010)
--targets-file FILE Read URLs from file (one per line, # comments)
--public-targets Use built-in public targets list
Authentication:
--auth-token TOKEN Bearer token for authenticated endpoints
(or set MCP_AUTH_TOKEN env var)
--dpop-proof JWT Optional static DPoP header value
--header KEY:VALUE Extra HTTP header (repeatable)
--tls-verify Enable TLS certificate verification
--oidc-scope SCOPE Optional OAuth2 scope for client_credentials
--token-introspect-url URL Optional OAuth2 token introspection endpoint
--token-introspect-client-id ID
--token-introspect-client-secret SECRET
--jwks-url URL Optional JWKS endpoint for keyset metadata
Scan Options:
--timeout SEC Per-target connection timeout (default: 25)
--workers N Parallel scan workers (default: 4)
Stdio Transport:
--stdio CMD Scan a local MCP server via stdin/stdout JSON-RPC
(e.g. --stdio 'npx -y @modelcontextprotocol/server-everything')
Safety Controls:
--no-invoke Static-only: skip all behavioral probes (safe for production)
--safe-mode Skip dangerous tools (delete/send/exec/write), probe read-only
--probe-calls N Invocations per tool for deep rug pull (default: 10)
Performance:
--fast Sample top 5 security-relevant tools, skip heavy probes
--probe-workers N Parallel deep behavioral probe threads (default: 1)
--deterministic Stable ordering + single-thread probes/AI Phase 2 for repeatable benchmarking
--claude-phase2-workers N Parallel Claude workers for AI Phase 2 (default: 1)
--bedrock Route Claude calls through AWS Bedrock runtime
--bedrock-region REGION Bedrock region (e.g. us-east-1)
--bedrock-profile PROFILE AWS profile for Bedrock credentials
--bedrock-model MODEL_ID Bedrock model ID (default: anthropic.claude-3-5-sonnet-20241022-v2:0)
Tool Server:
--tool-names-file FILE Custom wordlist for ToolServer enumeration (supplements built-in)
Output:
--json FILE Write JSON report to FILE
--group-findings Collapse similar findings into compact grouped rows
--no-color Disable colored output (respects NO_COLOR env var)
--verbose, -v Verbose output
--debug Debug output (very noisy)
Lane Reporting & Cross-Project Coverage:
--by-lane Group findings by agentic-identity lane (1..5),
print per-lane severity tally, and emit the
same structure into --json when both are set.
--coverage-report URL Fetch GET /api/lanes (schema v1) from a
running camazotz instance and print a
cross-project coverage report intersecting this
scan's findings with camazotz's lane corpus.
Diagnostic only — does NOT change the scanner's
exit code; failures (HTTP/schema mismatch) are
printed in red and the scan still exits based
on findings (see Exit Codes table).
--generate-policy FILE Generate a nullfield NullfieldPolicy YAML from
this scan's findings and write to FILE. Maps
code_execution / remote_access → DENY,
webhook_persistence → DENY, response_credentials
→ SCOPE redact, etc. Pairs naturally with
--no-invoke for safe production audits.
--policy-name NAME metadata.name for the generated policy
(default: mcpnuke-recommended).
--policy-namespace NS metadata.namespace for the generated policy.
Empty means cluster-scoped or set at apply time.
--policy-selector K=V spec.selector.matchLabels entry, repeatable.
Without it the selector is empty and matches
every pod — typically too broad for a real
cluster. For the camazotz reference deployment:
--policy-selector app=brain-gateway
--policy-labels K=V metadata.labels entry, repeatable. Useful for
tagging by lane/transport so dashboards group it.
Example: --policy-labels nullfield.io/lane=machine
Differential:
--baseline FILE Compare against baseline
--save-baseline FILE Save scan as baseline
Kubernetes:
--k8s-namespace NS Namespace for internal checks (default: default)
--no-k8s Skip Kubernetes checks
--k8s-discover Auto-discover MCP targets via K8s service discovery
--k8s-discover-namespaces Namespaces to scan for MCP services
--k8s-no-probe Skip active probing during discovery (port match only)
--k8s-discovery-workers N Concurrent MCP probes during discovery (default: 10)
--k8s-max-endpoints N Cap number of MCP endpoints to scan (no limit by default)
--k8s-discover-only List discovered endpoints only; skip MCP scanning扫描模式
| 模式 | 标志 | 运行内容 | 用例 |
|---|---|---|---|
| 满的 | (默认) | 静态+所有行为探针 | 开发/分期、DVMCP、CTF |
| 快 | --fast | 静态+前5名工具(分层评分),跳过重型探测(风险意识:保留 input_sanitization 当检测到危险参数时),将工作人员限制在2 | 快速分流,大型工具集 |
| 安全 | --safe-mode | 仅在只读工具上使用静态+探测 | 具有混合工具风险的Prod服务器 |
| 静态 | --no-invoke | 仅进行静态检查,不调用工具 | Prod服务器,无副作用风险 |
| 人工智能 | --claude | 所有检查+克劳德分析 | 深度分析,微妙的漏洞狩猎 |
快速模式评分
在 --fast 模式下,mcpnuke使用分层加权对所有发现的工具进行排名 评分算法(_tool_security_score)并选择前5名。得分手 考虑:
| 因素 | 它是如何工作的 |
|---|---|
| 关键字层 (6个级别) | Exec/eval/shell关键字得分最高(10),其次是秘密/凭证(8)、webhook/回调(7)、运行/命令(6)、上传/写入/文件(4)、管理员/root(3) |
| 名称与描述 | 工具中的关键字 *名字* 获得描述中关键字权重的3倍 |
| 危险参数 | 命名参数 url, command, code, query, script, host,等等,每个加+8 |
| 模式复杂性 | 输入属性的数量(最多3个)会增加一点额外的好处 |
| 高价值楼层 | 名称包含以下内容的工具 secret, credential, password, token, config等,即使其他信号较弱,也能获得最低15分 |
这确保了零参数工具,如 server-config 和 secrets.leak_config 排名高于良性工具,如 smelt-item 或 move-to-position,以及这些工具 具有危险参数的曲面(run-maintenance, admin-webhook, fetch-skin) 始终被选中。
人工智能分析(克劳德)
添加 --claude 在确定性检查之上进行任何扫描到层LLM推理。 需要 anthropic 包装和 ANTHROPIC_API_KEY 有人是。 默认情况下,mcpnuke使用直接的Claude API调用;Bedrock可通过以下方式选择加入 --bedrock.
设置:
# If installed via quickstart.sh or uv sync --all-extras, anthropic is included.
# Otherwise install the AI extra:
uv pip install -e ".[ai]" # or: pip install anthropic
export ANTHROPIC_API_KEY=sk-ant-...对于基岩模式,相同 ai 额外包括 boto3;配置AWS凭据 并通过 --bedrock (加上可选的区域/配置文件/型号标志)。
--claude 大声失败——没有钥匙,就没有跑步。 如果 --claude 已设置,但 anthropic 包裹丢失或 ANTHROPIC_API_KEY 未设置,mcpnuke 立即退出(退出代码 2)带有明确的错误信息 *之前* 任何 扫描开始。没有静默回退到存根响应程序。这是 故意:丢失密钥会将“AI扫描”降级为 仅使用相同的标志集进行确定性扫描,掩盖回归。 (Camazotz的大脑采取了相反的权衡,并退化为 [cloud-stub] 当密钥丢失时,响应器会自动响应——这对于实时演示非常有用, 但对安全工具来说是不安全的。)
用途:
# Sonnet (fast, default)
./scan --targets http://localhost:9002/sse --claude --verbose
# Opus (deepest reasoning)
./scan --targets http://localhost:9002/sse --claude --claude-model claude-opus-4-20250514
# Fast mode + Claude (deterministic fast scan, then AI analysis)
./scan --targets http://localhost:9090 --fast --claude --verbose
# Faster Claude Phase 2 on medium/large toolsets
./scan --targets http://localhost:9090 --fast --claude --claude-max-tools 25 --claude-phase2-workers 3
# Repeatable benchmarking mode (recommended for run-to-run comparisons)
./scan --targets http://localhost:9090 --fast --claude --deterministic --verbose
# Claude via Bedrock (no ANTHROPIC_API_KEY required)
./scan --targets http://localhost:9090 --fast --claude --bedrock --bedrock-region us-east-1--claude-phase2-workers 指导:
- 默认值为
1(连续)。这是安全的,开箱即用。 - 使用
2-4以在阶段2主导运行时减少挂钟时间。 - 保持
1如果您的密钥有速率限制或目标/网络不稳定。 - 此标志是可选的;扫描在没有它的情况下正常运行。
--deterministic 指导:
- 强制稳定的工具订购和单螺纹深探头/AI第2阶段。
- 当您需要更严格的运行间一致性时,请使用此功能进行基准测试和CI漂移检查。
- 这并没有完全消除模型/目标的不确定性,但它减少了扫描仪侧的方差。
mcpnuke使用三层分析架构。每一层都捕捉到了什么 前一个不能:
Layer 1: Deterministic (regex patterns) — what tools SAY
Layer 2: Behavioral (call tools, probe) — what tools DO
Layer 3: Claude AI (read, reason, chain) — what tools MEANClaude在确定性+行为检查后运行三个阶段:
| 阶段 | 它做什么 | 示例发现 |
|---|---|---|
| 工具分析 | 阅读微妙中毒、社会工程、逻辑风险的定义 | “这些工具连锁成特权升级路径” |
| 响应分析 | 读取实际工具输出以进行操纵、隐藏意图、凭证泄漏 | “工具响应是一个虚假的付费墙——LLM的社会工程” |
| 链式推理 | 将所有发现连接到多步攻击场景 | “未经身份验证的访问→ 指令注入→ 横向移动→ 坚持” |
DVMCP挑战4(Rug Pull)的真实示例:
| 图层 | 结果 | 分数 |
|---|---|---|
| 仅具有确定性 | 5(schema_risk、auth、SSE) | 26 |
| +行为探测 | 6(+深度_垃圾桶) | 36 |
| +克劳德·奥普斯 | 10(+社会工程、攻击链) | 64 |
人工智能发现以前缀 [AI] 并包括分类ID(例如。 [AI] [MCP-T03]). 它们与确定性发现一起出现在同一份报告中。
工具分类如下 危险的 如果他们的名字包含以下关键字 delete, execute, send, write, deploy, kill, transfer等等。 在 --safe-mode,在只读工具时跳过这些(get, list, search, check, verify等等)仍然被探测。
______________________________________________________________________
快速入门场景
扫描DVMCP(全部10个挑战)
# Terminal 1: start challenge servers
./tests/dvmcp_reset.sh --setup-only
# Terminal 2: scan
./scan --port-range localhost:9001-9010 --verbose自定义工具服务器(非MCP/执行API)
# Servers that use POST /execute with {"tool": "...", "query": "..."} instead of MCP
./scan --targets http://localhost:5000/execute --verbose
# With custom tool names wordlist for a specific engagement
./scan --targets http://localhost:5000/execute --tool-names-file my_tools.txt扫描仪通过探测20多个常用工具自动检测非MCP工具服务器 执行/调用路径和指纹框架(Flask、FastAPI、Express、, Spring Boot等)。工具从 内置单词表(data/tool_names.txt,84个名字)补充任何 自定义单词表。所有静态+行为检查都针对发现的工具运行。
经过身份验证的端点(GitHub MCP)
./scan --targets https://api.githubcopilot.com/mcp/ --auth-token ghp_xxx
# Or via env var
export MCP_AUTH_TOKEN=ghp_xxx
./scan --targets https://api.githubcopilot.com/mcp/远程公共MCP(DeepWiki)
./scan --targets https://mcp.deepwiki.com/mcp使用 /mcp (流式HTTP),不是 /sse.
差分扫描
# Save baseline
./scan --targets http://localhost:9001 --save-baseline baseline.json
# Later: detect regressions
./scan --targets http://localhost:9001 --baseline baseline.json报告添加/删除/修改了工具、资源、提示。新工具 标记为“中等”以供审查。
CI的JSON报告
./scan --port-range localhost:9001-9010 --json report.json退出代码为 1 如果扫描完成并报告结果, 0 如果干净, 和 2 扫描错误。在CI管道中使用,以控制部署和 将“发现”与“扫描仪故障”分开
运行测试
# Full suite
uv run pytest tests/ -v
# DVMCP challenges only
uv run pytest tests/test_dvmcp.py -v
# Stop on first failure
uv run pytest tests/ -v -x______________________________________________________________________
Kubernetes部署
将mcpnuke部署为K8s作业,以扫描集群内部MCP服务和 从内部审核Kubernetes的状态。
具有许多MCP的集群
当一个集群有许多服务(数十个或数百个潜在的MCP端点)时:
- 并行发现 --MCP探头与
--k8s-discovery-workers(默认值10)。
提高发现速度: --k8s-discovery-workers 20.
- 上限端点 --限制扫描的MCP数量:
--k8s-max-endpoints 50.
首先保留注释来源的端点;然后探测;然后进行端口匹配。
- 只发现分流 --列出不运行完整MCP扫描的端点:
mcpnuke --k8s-discover --k8s-discover-only --json endpoints.json 导出URL列表,以便在作业之间进行分类或拆分。
- 服务指纹识别 --对并行HTTP使用相同的worker计数
在枚举框架和暴露的执行器/调试路径时进行探测。
注: 使用mcpnuke(不是./scan)在K8s清单中——在 容器-该包是全局安装的。
快速部署
# Build the image
docker build -f mcpnuke/k8s/Dockerfile -t mcpnuke:latest .
# Deploy (read-only cluster access)
kubectl apply -k mcpnuke/k8s/manifests/
# Optional: enable full RBAC auditing (SA blast radius mapping)
kubectl apply -f mcpnuke/k8s/manifests/rbac-impersonate.yaml
# Check results
kubectl logs -n mcpnuke -l app.kubernetes.io/name=mcpnuke注: 基础部署授予对服务、Pod的只读访问权限, 机密、配置和网络策略。可选 rbac-impersonate.yaml 添加ServiceAccount模拟,使 扫描程序枚举目标中每个SA的有效权限 命名空间。这是一种提升的特权——只有在你愿意的情况下才能应用它 完成RBAC审计。没有它,扫描仪会优雅地降级。它在集群中检查什么
| 检查 | 它发现了什么 |
|---|---|
| RBAC枚举 | 扫描程序的SA可以访问哪些资源(机密、配置映射、Pod) |
| SA爆炸半径 | 为每个ServiceAccount映射有效权限;标记特权帐户 |
| Helm秘密扫描 | 解码Helm发布密钥(base64→base64→gzip)并扫描私钥和凭据的值 |
| Helm版本漂移 | 比较发布版本,以查找在较新版本中删除但仍可从旧版本中恢复的凭据 |
| 吊舱安全 | 特权容器、hostNetwork/PID、危险功能、hostPath挂载、根UID、缺少资源限制 |
| ConfigMap泄漏 | 扫描ConfigMap数据中的私钥和凭据命名字段 |
| 网络策略审核 | 标记没有网络策略的命名空间 |
| 服务指纹识别 | 识别框架(Spring Boot、Flask、Express等)和暴露的执行器、调试、swagger和管理端点的探测 |
| MCP发现 | 通过注释自动发现MCP服务器(mcp.io/enabled)众所周知的端口探测 |
| 工具服务器检测 | 检测非MCP工具执行API(POST /execute)通过使用工具式有效载荷进行探测;按名称枚举可用工具 |
重复扫描
使用CronJob清单进行定期审核:
kubectl apply -f mcpnuke/k8s/manifests/cronjob.yaml默认时间表:每6小时一次。编辑 spec.schedule 字段要更改。
定制
编辑 k8s/manifests/job.yaml 用于定位特定命名空间的args:
args:
- "--k8s-discover"
- "--k8s-discover-namespaces"
- "my-namespace"
- "--k8s-namespace"
- "my-namespace"
- "--verbose"
- "--json"
- "/reports/scan.json"______________________________________________________________________
项目结构
.
├── quickstart.sh # One-command setup (venv + install + tests)
├── scan # Zero-config runner (no venv activation needed)
├── mcpnuke/ # Python package
│ ├── __init__.py # Version, package docstring
│ ├── __main__.py # Entry point (python -m mcpnuke)
│ ├── cli.py # Argument parsing
│ ├── scanner.py # Scan orchestration, parallel execution, cross-target analysis
│ ├── diff.py # Differential scanning (baseline save/load/compare)
│ ├── core/
│ │ ├── constants.py # Protocol versions, severity weights, attack chain patterns
│ │ ├── enumerator.py # MCP handshake: initialize → list tools/resources/prompts
│ │ ├── models.py # Finding, TargetResult dataclasses
│ │ └── session.py # SSE + HTTP + Stdio + ToolServer transport detection and sessions
│ ├── patterns/
│ │ ├── rules.py # Static regex patterns (injection, poison, theft, exec, etc.)
│ │ └── probes.py # Behavioral probe payloads, canary strings, response analysis
│ ├── checks/
│ │ ├── __init__.py # Check registry and run_all_checks() orchestrator
│ │ ├── injection.py # prompt_injection, tool_poisoning, indirect_injection, active_prompt_injection
│ │ ├── permissions.py # excessive_permissions, schema_risks
│ │ ├── behavioral.py # rug_pull, deep_rug_pull, state_mutation, notification_abuse
│ │ ├── tool_probes.py # response_injection, input_sanitization, error_leakage
│ │ ├── theft.py # token_theft
│ │ ├── execution.py # code_execution, remote_access
│ │ ├── chaining.py # tool_shadowing, multi_vector, attack_chains
│ │ ├── transport.py # sse_security (CORS, unauth SSE, cross-origin POST)
│ │ ├── rate_limit.py # rate_limit
│ │ ├── prompt_leakage.py # prompt_leakage
│ │ ├── supply_chain.py # supply_chain
│ │ ├── webhook_persistence.py # webhook_persistence (name + param detection)
│ │ ├── credential_in_schema.py # credential_in_schema
│ │ ├── config_tampering.py # config_tampering
│ │ ├── exfil_flow.py # exfil_flow (source→sink with live verification)
│ │ └── response_credentials.py # response_credentials (cached response reuse)
│ ├── data/
│ │ ├── public_targets.txt # Built-in target URLs (DVMCP, public MCP servers)
│ │ └── tool_names.txt # Wordlist for ToolServer tool enumeration
│ ├── k8s/
│ │ ├── scanner.py # RBAC, Helm secrets, pod security, SA blast radius
│ │ ├── discovery.py # MCP auto-discovery via annotations + port probing
│ │ ├── fingerprint.py # Framework detection + exposed endpoint probing
│ │ ├── Dockerfile # Multi-stage Python 3.12-slim image
│ │ └── manifests/ # Kustomize-ready K8s deployment manifests
│ └── reporting/
│ ├── console.py # Rich table output
│ └── json_out.py # JSON report writer
├── tests/ # Pytest suite (224 tests, incl. DVMCP challenges)
│ ├── test_dvmcp.py # DVMCP challenges 1-10 (offline + optional live)
│ ├── test_cli.py # CLI argument parsing
│ ├── test_diff.py # Differential scanning
│ ├── test_k8s.py # Kubernetes checks
│ ├── test_fast_sampling.py # _tool_security_score + _pick_security_relevant
│ ├── test_webhook_persistence.py
│ ├── test_response_credentials.py
│ ├── test_exfil_flow.py
│ ├── test_config_tampering.py
│ ├── test_credential_in_schema.py
│ └── ...
├── walkthrough/ # Hands-on DVMCP guide + automated demo
│ ├── README.md # Progressive walkthrough with annotated findings
│ └── demo.sh # Zero-to-findings automated demo script
├── pyproject.toml # Project metadata, dependencies, entry points
├── CHANGELOG.md
└── README.md______________________________________________________________________
风险评分
Score = SUM(finding_weights)
CRITICAL → 10 points
HIGH → 7 points
MEDIUM → 4 points
LOW → 1 point
Rating:
≥ 20 → CRITICAL
≥ 10 → HIGH
≥ 5 → MEDIUM
≥ 1 → LOW
0 → CLEAN______________________________________________________________________
攻击链检测
在所有单独检查运行后,扫描仪会查找 链接的 漏洞对 它们组合成复合攻击路径:
| 链条 | 风险 |
|---|---|
prompt_injection → code_execution | 注射导致RCE |
prompt_injection → token_theft | 注射导致证书脱落 |
code_execution → token_theft | RCE用于窃取凭据 |
code_execution → remote_access | RCE到持久访问 |
indirect_injection → token_theft | 有毒数据泄露 |
tool_response_injection → cross_tool_manipulation | 输出劫持工具流 |
deep_rug_pull → tool_poisoning | 信任后工具突变 |
input_sanitization → code_execution | 对RCE的未授权输入 |
resource_poisoning → tool_response_injection | 有毒资源饲料工具 |
cross_tool_manipulation → token_theft | 工具链窃取信誉 |
webhook_persistence → tool_response_injection | 持久回调会提供中毒响应 |
webhook_persistence → token_theft | Webhook删除凭据 |
config_tampering → code_execution | 配置重写启用RCE |
config_tampering → webhook_persistence | 配置重写安装持久回调 |
response_credentials → token_theft | 泄露的信用证会导致进一步的盗窃 |
response_credentials → remote_access | 泄漏的奶油可以横向移动 |
exfil_flow → token_theft | 来源→水槽管道偷工减料 |
exfil_flow → remote_access | 来源→sink管道支持远程访问 |
使用基于证据的工具名称(例如。 input_sanitization → code_execution (execute_command))并出现在 扫描输出的“检测到攻击链”部分。
______________________________________________________________________
使用DVMCP进行测试
DVMCP 提供 10台故意易受攻击的MCP服务器用于测试:
| 挑战 | 端口 | 漏洞 |
|---|---|---|
| 1.基本提示注入 | 9001 | 资源中的敏感凭据 |
| 2.工具中毒 | 9002 | execute_command 和 shell=True |
| 3.权限过多 | 9003 | file_manager 读/写/删除 |
| 4.Rug Pull Attack | 9004 | N次调用后工具行为发生变化 |
| 5.工具阴影 | 9005 | 工具名称冲突 |
| 6.间接快速注射 | 9006 | 通过数据源注射 |
| 7.令牌盗窃 | 9007 | 密码/令牌作为参数 |
| 8.代码执行 | 9008 | eval() 用户输入 |
| 9.远程访问控制 | 9009 | 通过命令注入 remote_access |
| 10.多向量攻击 | 9010 | 连锁漏洞 |
# Run offline DVMCP challenge tests (no servers needed)
.venv/bin/pytest tests/test_dvmcp.py -v
# One-time setup for live testing
git clone https://github.com/harishsg993010/damn-vulnerable-MCP-server.git \
tests/test_targets/DVMCP
# Reset to baseline + start servers + scan (recommended)
./tests/dvmcp_reset.sh --scan
# Or step by step:
./tests/dvmcp_reset.sh # reset + start servers
./scan --port-range localhost:9001-9010 --verbose
# Scan specific challenges
./scan --targets http://localhost:9002 http://localhost:9008
# Deeper rug pull probing (more calls per tool, default is 10)
./scan --port-range localhost:9001-9010 --probe-calls 15
# Static-only scan (no tool calls)
./scan --port-range localhost:9001-9010 --no-invoke
# Run live DVMCP tests
DVMCP_LIVE=1 .venv/bin/pytest tests/test_dvmcp.py -v
# Kill servers + clean state
./tests/dvmcp_reset.sh --kill-only______________________________________________________________________
退出代码
| 代码 | 含义 |
|---|---|
| 0 | 干净--扫描已完成,未发现任何结果 |
| 1 | 调查结果——至少报告了一项调查结果 |
| 2 | 错误--扫描未成功完成(例如,无法到达目标、标记错误) |
文档中心
对于生态系统架构、演练和跨项目指南: 代理秒 --camazotz+nullfield+mcpnuke的中心文档。