0x00phantom-hat/CVE-2026-5029-Exploit
GitHub: 0x00phantom-hat/CVE-2026-5029-Exploit
针对 Code Runner MCP Server 未授权远程代码执行漏洞(CVE-2026-5029)的交互式漏洞利用工具,供授权渗透测试与安全研究使用。
Stars: 0 | Forks: 0
# 🔥 CVE-2026-5029 — Code Runner MCP Server RCE
### 通过 `run-code` MCP 工具实现未经身份验证的远程代码执行
[](https://nvd.nist.gov/vuln/detail/CVE-2026-5029)
[](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2026-5029)
[](https://python.org)
[](#-漏洞概述)
[](#-免责声明)
## 📋 漏洞概述
| 属性 | 详情 |
| ---------------------- | ----------------------------------------------------------------------------------------------- |
| **CVE ID** | [CVE-2026-5029](https://nvd.nist.gov/vuln/detail/CVE-2026-5029) |
| **CVSS Score** | **8.7 / 10 — 高危** |
| **CWE** | [CWE-306](https://cwe.mitre.org/data/definitions/306.html) — 关键功能缺少身份验证 |
| **受影响产品** | [Code Runner MCP Server](https://github.com/formulahendry/mcp-server-code-runner) |
| **受影响版本** | (未修补)所有通过 `--transport http` 暴露 `run-code` 工具的版本 |
| **身份验证** | **无需身份验证** (Unauthenticated) |
| **补丁状态** | **未修复** |
| **发现者** | [Phantom Hat](https://github.com/0x00phantom-hat) |
## 🧠 技术描述
**Code Runner MCP Server** 在使用 `--transport http` 标志启动时,会在 **port 3088** 上暴露 JSON-RPC `/mcp` endpoint。此 endpoint 可以在 **零身份验证** 的情况下访问 —— 无需 API key、session token 或 origin 校验。
任何能够访问该端口的未经身份验证的远程攻击者都可以直接调用 `run-code` MCP 工具,该工具接受任意源代码和语言标识符,将其写入临时文件,并通过 `child_process.exec()` 使用相应的解释器(`bash`、`python`、`powershell` 等 30 多种)执行它。
由于在任何阶段都没有对 `code` 参数进行过滤或清理,这会导致以运行 MCP 服务器的进程的权限进行 **完全未经身份验证的远程代码执行**。
# 案例研究
https://medium.com/@phantom_hat/cve-2026-5029-unpatched-case-study-unauthenticated-remote-code-execution-rce-66c7706f2320
### 攻击流程
```
┌──────────┐ JSON-RPC tools/call ┌───────────────────────┐ exec() ┌──────────┐
│ Attacker │ ──── run-code tool ─────▶│ /mcp (port 3088) │ ─────────▶ │ RCE │
│ │ (no auth needed) │ Code Runner MCP │ │ on Host │
└──────────┘ └───────────────────────┘ └──────────┘
```
1. **侦察** — 连接到暴露的 `/mcp` endpoint 并枚举可用的 MCP 工具
2. **Schema 发现** — 获取 `run-code` 工具的输入 schema(`code`、`languageId`)
3. **利用载荷投递** — 发送带有攻击者控制的 `code` 的伪造 `tools/call` JSON-RPC 请求
4. **命令执行** — 服务器将 `code` 写入临时文件,并通过选定的解释器执行
## 🗂️ 仓库结构
```
.
├── exploit.py # 🎯 Interactive RCE exploit shell (Rich-based terminal UI)
└── README.md # 📖 You are here
```
### `exploit.py` — 交互式漏洞利用
主要的漏洞利用脚本,专为安全评估和案例研究的专业用途而构建。它连接到目标 MCP 服务器并进入交互式 shell,在其中通过存在漏洞的 `run-code` 工具实时执行任何命令。
功能包括:
- 使用 [Rich](https://github.com/Textualize/rich) 输出干净且结构化的终端信息
- 交互式漏洞利用 shell —— 输入命令,获取输出,来回交互,无需重新运行脚本
- 语言枚举 —— 列出 MCP 服务器声明支持的所有语言
- 已安装语言探测 —— 检查目标主机上实际存在哪些解释器
- 通过 `-l` 选择执行语言(默认为 `shellscript`)
- 用于详细操作输出的 Verbose 模式
## ⚙️ 安装说明
### 前置条件
- Python 3.8+
- `pip` 包管理器
### 设置
```
# Clone the repository
git clone https://github.com/0x00phantom-hat/CVE-2026-5029-RCE-Exploit.git
cd CVE-2026-5029-RCE-Exploit
# Install dependencies
pip install fastmcp rich
```
## 🚀 用法
```
# Drop into an interactive RCE shell (默认: shellscript)
python3 exploit.py -u http://TARGET:3088/mcp
# Use a specific language interpreter
python3 exploit.py -u http://TARGET:3088/mcp -l python
# List all languages the MCP server advertises support for
python3 exploit.py -u http://TARGET:3088/mcp --available
# Probe which language runtimes are actually installed on the target
python3 exploit.py -u http://TARGET:3088/mcp --installed -v
# Show the help menu
python3 exploit.py -h
```
连接后,漏洞利用程序将进入交互式提示符:
```
PhantomHat-MCP@Exploit-CVE-2026-5029 $ id
```
输入 `exit` 关闭会话。
### 命令行参数
| 参数 | 描述 | 默认值 |
| -------------------- | ----------------------------------------------- | -------------- |
| `-u`, `--url` | **(必需)** MCP 服务器 URL | — |
| `-l`, `--language` | 用于代码执行的语言 | `shellscript` |
| `-a`, `--available` | 列出所有支持的语言 | 参数标志 |
| `-i`, `--installed` | 探测目标上已安装的语言运行时 | 参数标志 |
| `-v`, `--verbose` | 详细输出模式 | 参数标志 |
| `-h`, `--help` | 显示帮助菜单 | — |
## 📸 漏洞利用阶段
| 阶段 | 名称 | 描述 |
| ----- | ------------------------ | ------------------------------------------------------------------ |
| **1** | 🔍 枚举 | 连接到 `/mcp` 并枚举可用的 MCP 工具 |
| **2** | 🧪 Schema 发现 | 确认 `run-code` 的输入 schema(`code`、`languageId`) |
| **3** | 💣 利用载荷投递 | 发送带有攻击者控制的代码的伪造 `tools/call` 请求 |
| **4** | 🚀 交互式执行 | 掉入实时 shell —— 每个命令都在目标主机上运行 |
## 🔗 参考
- **NVD:**
- **CERT.PL Advisory:**
- **存在漏洞的项目:**
- **存在漏洞的 Sink (server.ts):**
## 🛡️ 修复方案
- **切勿** 在任何网络可达的接口上运行 `--transport http` —— 坚持使用默认的 `stdio` 传输
- **如果必须使用 HTTP 传输**,请严格绑定到 `127.0.0.1`,并将其置于经过身份验证的反向代理或 VPN 之后
- 在主机或网络级别对 **3088 端口设置防火墙**
- **以低权限的沙箱用户身份或锁定权限的容器内运行服务器**
- **监控** 意外的 `run-code` 调用和异常的子进程
## ⚠️ 免责声明
**作者:** Phantom Hat
*仅用于授权的渗透测试和安全研究。*
标签:Maven, MCP Server, Python, 无后门, 漏洞验证, 编程工具, 远程代码执行, 逆向工具