keraattin/CVE-2026-33032
GitHub: keraattin/CVE-2026-33032
一款针对 nginx-ui 未认证 RCE 漏洞的轻量检测工具,核心解决 MCP 接口绕过认证的风险识别问题。
Stars: 0 | Forks: 0
# CVE-2026-33032 / MCPwn
[](https://nvd.nist.gov/vuln/detail/CVE-2026-33032)
[](https://nvd.nist.gov/vuln/detail/CVE-2026-33032)
[]()
[](https://github.com/0xjacky/nginx-ui)
[](#license)
[](#requirements)
## 目录
1. [快速要点](#quick-facts)
2. [漏洞概述](#vulnerability-overview)
3. [技术深入分析](#technical-deep-dive)
4. [检测策略](#detection-strategy)
5. [安装](#installation)
6. [用法](#usage)
7. [示例输出](#example-output)
8. [与 CVE-2026-27944 联动](#chain-with-cve-2026-27944)
9. [修复](#remediation)
10. [负责任使用](#responsible-use)
11. [参考](#references)
12. [许可证](#license)
## 快速要点
| 字段 | 值 |
|------------------------|---------------------------------------------------------------|
| CVE ID | CVE-2026-33032 |
| 别名 | MCPwn |
| CVSS 3.1 | 9.8 / 严重 (AV:N / AC:L / PR:N / UI:N / S:U / C:H/I:H/A:H)|
| CWE | CWE-306 关键功能缺少身份验证 |
| 受影响产品 | nginx-ui (github.com/0xjacky/nginx-ui) |
| 受影响版本 | 2.3.4 之前的所有版本 |
| 修复版本 | 2.3.4 |
| 漏洞利用状态 | 野外活跃 (Picus Security, Recorded Future) |
| Shodan 暴露 | ~2,689 个互联网暴露实例 |
| 发布日期 | 2026-04-15 |
## 漏洞概述
nginx-ui 暴露了模型上下文协议 (MCP) 接口,允许经过身份验证的操作员通过 JSON-RPC 驱动破坏性工具,例如 nginx 配置编辑、重启命令和备份操作。
`/mcp` 端点受到 `AuthRequired()` 中间件的保护,而其配对的 `/mcp_message` 端点(实际接收工具调用)**未**部署该中间件。任何可以访问网络上的 UI 的客户端都可以:
1. 打开到 `/mcp` 的服务器发送事件 (SSE) 流,在不提供任何凭证的情况下接收新的 `sessionID`。
2. 使用该 `sessionID` 通过 POST 到 ` `/mcp_message` 调用任何已注册的 MCP 工具,仍然未经过身份验证。
攻击者获得对 nginx 进程的完全控制:编辑服务器块以重定向流量、通过路径读取提取 TLS 私钥、重新加载或停止 nginx,并植入持久性后门。
## 技术深入分析
### 代码级根本原因
```
// vulnerable (pre-2.3.4)
r.GET("/mcp", AuthRequired(), mcpHandler)
r.POST("/mcp_message", mcpMessageHandler) // missing middleware
// fixed in 2.3.4
r.GET("/mcp", AuthRequired(), mcpHandler)
r.POST("/mcp_message", AuthRequired(), mcpMessageHandler)
```
一个缺失的函数调用就足以将 MCP 接口变成未经身份验证的 RCE 网关。
### 端到端攻击素描
```
Attacker nginx-ui (<2.3.4)
| 1) GET /mcp (no auth) |
| --------------------------------------> |
| 2) event: endpoint data: /mcp_message?sessionID=XYZ
| <-------------------------------------- |
| 3) POST /mcp_message?sessionID=XYZ |
| body: JSON-RPC call_tool "nginx_reload" or
| "edit_config {...}" |
| --------------------------------------> |
| 4) 200 OK; tool executed with full privileges
| <-------------------------------------- |
```
### 影响矩阵
| MCP 工具 | 对 nginx 服务器影响 |
|------------------------------|-----------------------------------------------------------------|
| `edit_config` | 重写任意服务器块,插入攻击者上游 |
| `reload_nginx` | 在无需手动操作的情况下应用攻击者配置 |
| `stop_nginx` | 拒绝服务 |
| `read_file` | 渗出 TLS 私钥和挂载路径中的凭证 |
| `create_cert` | 在攻击者控制下重新签发 TLS 证书 |
| `list_backups` / `download` | 拉取包含 node_secret 和哈希的完整 nginx-ui 备份 |
## 检测策略
本存储库故意不执行任何破坏性操作。检测器仅使用只读 MCP 方法 (`tools/list`)。逻辑如下:
```
> Step 1 Fingerprint nginx-ui via
> GET / (HTML title, JS bundles)
> GET /api/settings (JSON referencing nginx-ui keys)
> Extract version via header / body regex
> Step 2 Open SSE stream to /mcp
> Parse the first sessionID from the "endpoint" event
> Step 3 POST /mcp_message?sessionID=
> Body: {"jsonrpc":"2.0","method":"tools/list","params":{}}
> No Authorization header
> Step 4 Vulnerable if status 200 and body contains a tool manifest
> Patched if status 401 / 403 / 404
> Inconclusive otherwise
```
### 为何安全
`tools/list` JSON-RPC 方法是只读的。它枚举 MCP 服务器了解的工具,但不会调用其中任何一个。该脚本拒绝 POST 任何其他方法,也不会为破坏性工具构造有效载荷。
## 安装
```
git clone https://github.com/your-org/CVE-2026-33032-detector.git
cd CVE-2026-33032-detector
python3 --version # 3.9 or newer
# 无需第三方软件包
```
对于 Nmap NSE 组件,将 `nginx-ui-mcpwn.nse` 复制到本地脚本目录并刷新脚本数据库:
```
cp nginx-ui-mcpwn.nse /usr/share/nmap/scripts/
sudo nmap --script-updatedb
```
## 用法
### Python 检测器
```
# 单目标
python3 detect_nginx_ui_mcpwn.py --target https://nginx-ui.internal
# 从文件批量扫描
python3 detect_nginx_ui_mcpwn.py --targets targets.txt --workers 20
# 适用于管道传输至 jq 的 JSON(NDJSON)输出
python3 detect_nginx_ui_mcpwn.py --target 10.0.0.5:9000 --json | jq .
```
命令行参考:
| 标志 | 用途 |
|-----------------|--------------------------------------------------------|
| `--target` | 单个 URL 或 host[:port] |
| `--targets` | 以换行符分隔的目标文件 |
| `--timeout` | HTTP 超时,默认 10 秒 |
| `--workers` | 批量扫描的并发工作线程,默认 10 |
| `--verify-tls` | 强制 TLS 证书验证(默认关闭) |
| `--json` | 输出 NDJSON,每条记录一个目标 |
| `--no-banner` | 抑制 ASCII 横幅 |
### Nmap NSE
```
nmap -p 80,443,9000 --script nginx-ui-mcpwn 10.0.0.0/24
nmap -p 443 --script nginx-ui-mcpwn --script-args "nginx-ui-mcpwn.timeout=8" host.example.com
```
## 示例输出
### 人类可读
```
_ _ _ _ _ ___ __ __ ____ ____
| \ | | __ _(_)_ __ __ __ | | | ||_ _| | \/ |/ ___| _ \__ ___ __
| \| |/ _` | | '_ \\ \/ /_____| | | | | | | |\/| | | | |_) \ \ /\ / / '_ \
| |\ | (_| | | | | |> <|_____| |__| | | | | | | | |___| __/ \ V V /| | | |
|_| \_|\__, |_|_| |_/_/\_\ |_____|_||___| |_| |_|\____|_| \_/\_/ |_| |_|
|___/
CVE-2026-33032 nginx-ui MCPwn Detector > non-destructive
[!] VULNERABLE https://nginx-ui.internal version=2.3.2 evidence=status=200; body_preview={"jsonrpc":"2.0","id":"...","result":{"tools":[{"name":"edit_config",...
[+] patched https://nginx-ui-patched:9000 version=2.3.4 evidence=status=401; body_preview={"error":"unauthorized"}
[.] not nginx-ui https://example.com evidence=fingerprint negative
Summary: 1/3 targets flagged vulnerable
```
### NDJSON
```
{"target":"https://nginx-ui.internal","reachable":true,"is_nginx_ui":true,"mcp_endpoint_present":true,"session_id_obtained":true,"mcp_message_unauthenticated":true,"vulnerable":true,"nginx_ui_version":"2.3.2","evidence":"status=200; body_preview=...","error":null}
```
### Nmap
```
PORT STATE SERVICE
9000/tcp open http
| nginx-ui-mcpwn:
| status: VULNERABLE
| version: 2.3.2
| session_id: abc123
|_ evidence: tools/list accepted without credentials
```
## 与 CVE-2026-27944 联动
`CVE-2026-27944`(未经身份验证的 `/api/backup` 下载,会在 `X-Backup-Security` 头中泄露 AES 密钥)可以干净利落地与 MCPwn 联动:备份存档暴露了 `node_secret`,可用于在 33032 的修复生效后对 `/mcp` 进行身份验证,直到操作员轮换密钥。
该漏洞 27944 的配套检测器位于本研究项目的同级目录中。
## 修复
1. 将 nginx-ui 升级到 **2.3.4** 或更高版本。
2. 轮换 `node_secret`、管理员密码哈希以及任何对 nginx-ui 进程可访问的 TLS 私钥。
3. 限制 nginx-ui 的暴露范围至管理 VLAN、VPN 或强制在访问 `/mcp_message` 路由前进行身份验证的反向代理。
4. 审查 nginx 配置历史记录(Git 或备份),查找在暴露窗口期间引入的意外 upstream / proxy_pass / ssl_certificate 指令。
## 负责任使用
本工具发布用于帮助防御者识别其被授权测试环境中的未修补实例。请勿用于您未拥有或未经明确许可评估的系统。作者拒绝承担任何滥用责任。
## 参考
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-33032
- Picus Security (MCPwn 写入): https://www.picussecurity.com/resource/blog/cve-2026-33032-mcpwn-how-a-missing-middleware-call-in-nginx-ui-hands-attackers-full-web-server-takeover
- Security Affairs: https://securityaffairs.com/190841/hacking/cve-2026-33032-severe-nginx-ui-bug-grants-unauthenticated-server-access.html
- BleepingComputer: https://www.bleepingcomputer.com/news/security/critical-nginx-ui-auth-bypass-flaw-now-actively-exploited-in-the-wild/
- 上游项目: https://github.com/0xjacky/nginx-ui
标签:API安全, CVE-2026-33032, JSON输出, MCPwn, Nginx UI, Python, RCE, 函数调用缺失, 安全防护, 无后门, 服务端安全, 未认证远程代码执行, 漏洞分析, 网络安全, 认证绕过, 路径探测, 路由注册, 远程执行, 逆向工具, 隐私保护