
Advanced security research on CVE-2025-55182 (React2Shell). Features an exploitation framework with 6 functional impact scenarios (RCE to Secret Exfiltration), an interactive reverse shell, and a complete laboratory. Portfolio piece demonstrating deep analysis of Prototype Pollution and Insecure Deserialization in React Server Components
不可信数据反序列化 + React Server Components 中的原型污染
通过 Next.js Server Actions 实现未经认证的远程代码执行
受影响版本: React 19.0.0 - 19.2.0 · 补丁: React 19.0.1 / 19.1.2 / 19.2.1 (2025年12月3日)
高级利用演示 - RCE基本命令、交互式Shell以及针对易受攻击的Next.js应用的多种攻击向量
该仓库包含我关于 CVE-2025-55182 的 硕士论文研究,这是 React Server Components 中的一个严重(CVSS v3.1: 10.0)远程代码执行漏洞。
该漏洞源于 React Flight 协议中的不安全反序列化机制。在处理 Server Actions 时,Next.js 会反序列化传入的多部分负载而未经适当验证。攻击者可以构造恶意负载,污染原型链并注入任意 JavaScript,这些代码通过 Function 构造函数(继而通过 child_process.execSync())在服务器上执行。
关于 CVE-2025-66478 的说明: Vercel 发布了一个并行的 CVE 来追踪同一漏洞在 Next.js 中的特定影响。由于 Next.js 以捆绑(vendored)方式引入 React,许多依赖扫描器不会自动检测到该漏洞。美国国家漏洞数据库(NVD)正式驳回了 CVE-2025-66478,认为其是 CVE-2025-55182 的重复,尽管它仍然在 Vercel 自身的安全公告中被引用。
后续漏洞: React团队随后披露了两个在初始补丁版本(19.0.1, 19.1.2, 19.2.1)中存在的附加问题:CVE-2025-55184(拒绝服务,CVSS 7.5)和 CVE-2025-55183(源代码泄露,CVSS 5.3)。用户应升级到 19.0.2, 19.1.3 或 19.2.2 以解决所有三个问题。
CVE-2025-55182/
├── README.md # This file
├── LICENSE # MIT License
│
├── exploit/
│ ├── exploit-explanation.md # Exploit usage documentation
│ └── react2shell.py # Main exploit — 4 attack modules + interactive shell
│
├── vulnerable-app/ # Vulnerable Next.js application
│ ├── README.md # Original vulnapp credits
│ ├── package.json # React 19.0.0 (vulnerable)
│ ├── app/ # Application source code
│ ├── curl_id.sh # Original exploit script (by zack0x01)
│ └── scripts/
│ └── restore.sh # Restoration script (my contribution)
│
└── docs/
├── screenshots/ # Exploitation demonstrations
│ ├── 01-app-initial.png
│ ├── 02-rce-basic.png
│ ├── 03-interactive-shell.png
│ ├── 04-no-payload.png
│ ├── 05-delete-result.png
│ ├── 06-deface.png
│ ├── 07-shutdown-servers.png
│ ├── 08-restore-from-script.png
│ └── 09-restore-from-interactive-shell.png
│
└── analysis/
├── 01-root-cause.md # Vulnerability root cause analysis
├── 02-payload-breakdown.md # Payload structure and execution flow
└── 03-timeline.md # CVE timeline
vulnerable-app/)cd vulnerable-app
npm install --legacy-peer-deps
npm run dev
# App available at http://localhost:3000
cd ../exploit
# Check if target is vulnerable
python3 react2shell.py -u http://localhost:3000 --check
# Execute single command
python3 react2shell.py -u http://localhost:3000 -c "whoami"
# Interactive shell mode
python3 react2shell.py -u http://localhost:3000 -i
React Server Components 使用自定义的序列化/反序列化机制("Flight" 协议)将组件数据从服务器发送到客户端。在处理服务端操作(Server Actions)时,服务器会在没有适当验证的情况下反序列化传入的负载。
核心缺陷是行为信任:反序列化器检查 typeof obj.then === 'function' 以识别 Promise,但没有验证该属性是否直接属于该对象。这使得攻击者可以污染 Object.prototype.then,使每个普通对象看起来都像是一个 thenable 对象。
攻击者可以构造一个恶意负载,实现:
__proto__:thenFunction 构造函数 — 通过 $1:constructor:constructornew Function(_prefix)process.mainModule.require('child_process').execSync()X-Action-Redirect 外渗输出用户模式(未经认证)
│
├─ POST / (Next.js Server Action 端点)
│ ├─ 头: Next-Action: x
│ └─ 包含恶意JSON的多部分正文
│
└─ React Flight 反序列器处理负载
└─ 通过 __proto__:then 进行原型污染
└─ 通过 $1:constructor:constructor 到达 Function 构造函数
└─ new Function(_prefix) 执行攻击者的JavaScript
└─ execSync() 运行系统命令
└─ 输出嵌入到 NEXT_REDIRECT 错误中
└─ Next.js 转换为 X-Action-Redirect 头
该漏洞影响任何使用 App Router 和 React Server Components 的 Next.js 应用 — 这是 Next.js 14 以后的默认配置。不需要显式定义 Server Actions;存在受影响的 RSC 包就足够了。
该漏洞允许未经认证的攻击者:
1. [任意] 向任意 Server Action 端点发送精心构造的多部分 POST 请求
2. [服务器] React 反序列器处理恶意 JSON
3. [服务器] 原型污染污染 Object.prototype.then
4. [服务器] 普通对象被视为 thenable;到达 Function 构造函数
5. [服务器] new Function(_prefix) 执行攻击者的任意 JavaScript
6. [服务器] execSync() 运行系统命令;捕获输出
7. [服务器] 输出嵌入到 NEXT_REDIRECT 错误摘要中
8. [服务器] Next.js 返回带有 URL 编码输出的 X-Action-Redirect 头
9. [攻击者] 从头中提取并 URL 解码命令结果
所有测试均在隔离的 VirtualBox 虚拟机上进行,运行 Kali Linux 2026.1,并安装 Next.js 15.0.0 和 React 19.0.0,未暴露网络。
确定性: 与概率性利用(如堆喷)不同,CVE-2025-55182 完全确定——任何格式正确的 HTTP POST 请求在运行 React 19.0.0–19.2.0 并启用 React Server Components 的未修补系统上,都会以概率 1 产生 RCE。
本项研究是我 网络安全硕士论文 (UCAM — Campus Internacional de Ciberseguridad) 的一部分,旨在分析跨多种环境的 N 日漏洞。
该 CVE 代表了论文中的 现代 JavaScript 框架 向量,展示了:
关键词: RCE · Prototype Pollution · Deserialization · React · Next.js · Server Actions · CVE-2025-55182
Annais Molina (devianntsec) — 安全研究员 | 网络安全硕士 (UCAM)
MIT 许可证 — 参见 LICENSE
本仓库仅供教育和安全研究目的使用,作为学术硕士论文的一部分。所有测试均在隔离的虚拟机上执行,未暴露网络。仅在你拥有或已获明确书面授权测试的系统上使用。未经授权对系统进行测试是违法的,并可能导致刑事起诉。
| 方面 | 描述 |
|---|
| 四个攻击模块 | 删除项目、篡改网站、窃取环境变量、关闭服务器 |
| 交互式Shell | 带有特殊命令和恢复能力的持久Shell |
| 稳定外渗 | 逐行读取以绕过HTTP头大小限制 |
| 恢复脚本 | 攻击后的安全实验室恢复 |
| 学术文档 | 根本原因、负载分解和漏洞时间线 |
| 模块 | 命令 | 描述 | 影响 |
|---|
| 删除项目 | --delete-projects | 从仪表板删除所有项目 | 数据破坏 |
| 篡改 | --deface "message" | 替换主页面 | 篡改 |
| 窃取环境 | --steal-env | 窃取环境变量 | 外渗 |
| 关闭服务器 | --shutdown-servers | 关闭所有服务器 | 拒绝服务 |
| 攻击模块 | 结果 | 备注 |
|---|
| 命令执行 | ✅ RCE 确认 | whoami、id、uname -a 可靠工作 |
| 删除项目 | ✅ 仪表板已修改 | 项目被移除,React 结构保持完整 |
| 篡改 | ✅ 网站被篡改 | 显示自定义消息 |
| 窃取环境 | ✅ 环境变量被提取 | 保存到 stolen_env.txt |
| 关闭服务器 | ✅ 所有服务器显示为已停止 | UI 更新,React 功能正常 |
| 交互式Shell | ✅ 持久Shell | 可以使用特殊命令 |
| 恢复 | ✅ 恢复至原始状态 | 通过 restore.sh 脚本 |
| 发现、披露和补丁时间线 |