devianntsec/CVE-2025-55182

GitHub: devianntsec/CVE-2025-55182

针对 React Server Components 原型链污染 RCE 漏洞(CVE-2025-55182)的高级利用框架,包含多种攻击模块、交互式 Shell 和完整靶场实验室。

Stars: 0 | Forks: 0

# CVE-2025-55182 — React2Shell:高级漏洞利用与硕士论文研究 [![平台](https://img.shields.io/badge/Platform-Web%20Application-blue)](https://nvd.nist.gov/vuln/detail/CVE-2025-55182) [![语言](https://img.shields.io/badge/Language-Python-informational)](https://github.com/devianntsec) [![许可证: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![研究](https://img.shields.io/badge/Research-Master's%20Thesis-purple)](https://github.com/devianntsec) [![CVSS](https://img.shields.io/badge/CVSS-10.0%20(Critical)-亮红色)](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

高级漏洞利用演示 - RCE 基础命令、交互式 shell 以及针对易受攻击的 Next.js 应用程序的多种攻击向量

## 描述 本代码库包含我关于 **CVE-2025-55182** 的**硕士论文研究**,这是 React Server Components 中的一个严重 (CVSS v3.1: 10.0) **远程代码执行 (RCE)** 漏洞。 该漏洞源于 React Flight 协议中的一个**不安全的反序列化机制**。在处理 Server Actions 时,Next.js 在没有适当验证的情况下反序列化传入的 multipart payload。攻击者可以精心构造一个恶意 payload 来污染原型链并注入任意 JavaScript,该 JavaScript 通过 `Function` 构造函数在服务器上执行(随后通过 `child_process.execSync()` 执行)。 ### 我的贡献 | 方面 | 描述 | |--------|-------------| | **四个攻击模块** | 删除项目、篡改网页、窃取环境变量、关闭服务器 | | **交互式 shell** | 具有特殊命令和恢复功能的持久化 shell | | **稳定的数据外发** | 逐行读取以绕过 HTTP 标头大小限制 | | **恢复脚本** | 攻击后安全的实验室环境恢复 | | **学术文档** | 根本原因、payload 解析以及漏洞时间线 | ## 代码库结构 ``` 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 ``` ## 快速开始 ### 前置条件 - Node.js 18+ 和 npm - Python 3.9+ - 易受攻击的 Next.js 应用程序(在 `vulnerable-app/` 中提供) - 建议在隔离的虚拟机中进行测试 ### 步骤 1 — 启动易受攻击的应用程序 ``` cd vulnerable-app npm install --legacy-peer-deps npm run dev # 应用可在 http://localhost:3000 访问 ``` ### 步骤 2 — 运行漏洞利用程序 ``` cd ../exploit # 检查目标是否存在漏洞 python3 react2shell.py -u http://localhost:3000 --check # 执行单个命令 python3 react2shell.py -u http://localhost:3000 -c "whoami" # 交互式 shell 模式 python3 react2shell.py -u http://localhost:3000 -i ``` ## 攻击模块 | 模块 | 命令 | 描述 | 影响 | |--------|---------|-------------|--------| | **删除项目** | `--delete-projects` | 从仪表板删除所有项目 | 数据破坏 | | **篡改网页** | `--deface "message"` | 替换主页 | 网页篡改 | | **窃取环境** | `--steal-env` | 窃取环境变量 | 数据窃取 | | **关闭服务器** | `--shutdown-servers` | 关闭所有服务器 | 拒绝服务 | ## 技术概述 ### 漏洞根本原因 React Server Components 使用自定义的序列化/反序列化机制(即 "Flight" 协议)从服务器向客户端发送组件数据。在处理 Server Actions 时,服务器在**没有适当验证**的情况下反序列化传入的 payload。 核心缺陷在于行为信任:反序列化器检查 `typeof obj.then === 'function'` 来识别 Promise,而没有验证该属性是否直接属于该对象。这允许攻击者污染 `Object.prototype.then`,使每个普通对象都表现为一个 thenable 对象。 攻击者可以精心构造一个恶意 payload 来: 1. 使用 `__proto__:then` **污染原型链** 2. 通过 `$1:constructor:constructor` **将解析重定向**到 `Function` 构造函数 3. 通过 `new Function(_prefix)` **执行任意 JavaScript** 4. 通过 `process.mainModule.require('child_process').execSync()` **运行系统命令** 5. 通过 `X-Action-Redirect` HTTP 响应头**外发输出** ``` User-mode (unauthenticated) │ ├─ POST / (Next.js Server Action endpoint) │ ├─ Headers: Next-Action: x │ └─ Multipart body with malicious JSON │ └─ React Flight deserializer processes payload └─ Prototype pollution via __proto__:then └─ Function constructor reached via $1:constructor:constructor └─ new Function(_prefix) executes attacker's JavaScript └─ execSync() runs system command └─ Output embedded in NEXT_REDIRECT error └─ Next.js converts to X-Action-Redirect header ``` ### 影响范围说明 该漏洞影响任何使用**带有 React Server Components 的 App Router** 的 Next.js 应用程序——这是自 Next.js 14 以来的默认配置。**不需要**显式定义的 Server Actions;仅仅存在受影响的 RSC 包就足够了。 ### 为什么它很重要 此漏洞允许未经身份验证的攻击者: - 在服务器上执行任意命令 - 窃取环境变量和凭据 - 修改或删除应用程序数据 - 将服务器作为进一步攻击的跳板 ### 攻击链 ``` 1. [ANY] Send crafted multipart POST to any Server Action endpoint 2. [SERVER] React deserializer processes malicious JSON 3. [SERVER] Prototype pollution poisons Object.prototype.then 4. [SERVER] Plain object treated as thenable; Function constructor reached 5. [SERVER] new Function(_prefix) executes attacker's arbitrary JavaScript 6. [SERVER] execSync() runs system command; output captured 7. [SERVER] Output embedded in NEXT_REDIRECT error digest 8. [SERVER] Next.js returns X-Action-Redirect header with URL-encoded output 9. [ATTACKER] Extract and URL-decode command result from header ``` ## 实证测试 所有测试均在运行 Kali Linux 2026.1、Next.js 15.0.0 和 React 19.0.0 的隔离 VirtualBox 虚拟机上进行,无网络暴露。 | 攻击模块 | 结果 | 备注 | |---------------|--------|-------| | 命令执行 | ✅ 确认 RCE | `whoami`、`id`、`uname -a` 运行可靠 | | 删除项目 | ✅ 仪表板已修改 | 项目已移除,React 结构保留 | | 篡改网页 | ✅ 网站已篡改 | 显示自定义消息 | | 窃取环境 | ✅ 环境变量已提取 | 保存到 `stolen_env.txt` | | 关闭服务器 | ✅ 所有服务器显示为已停止 | UI 已更新,React 功能正常 | | 交互式 shell | ✅ 持久化 shell | 特殊命令可用 | | 恢复 | ✅ 原始状态已恢复 | 通过 `restore.sh` 脚本 | **确定性:** 与概率性漏洞利用(例如 heap spray)不同,CVE-2025-55182 是完全确定性的——任何格式正确的 HTTP POST 请求都能在运行 React 19.0.0–19.2.0 且启用了 React Server Components 的任何未修补系统上产生 RCE,概率为 1。 ## 技术文档 | 文档 | 描述 | |----------|-------------| | [根本原因分析](docs/analysis/01-root-cause.md) | React Flight 中的反序列化缺陷与原型链污染 | | [Payload 解析](docs/analysis/02-payload-breakdown.md) | 恶意 JSON 结构的逐行分析 | | [CVE 时间线](docs/analysis/03-timeline.md) | 发现、披露和补丁时间线 | ## 学术背景 本研究是我的**网络安全硕士学位**(UCAM — Campus Internacional de Ciberseguridad)论文的一部分,旨在分析跨多种环境的 N-Day 漏洞。 此 CVE 代表了论文中的**现代 JavaScript 框架**攻击向量,演示了: - React Server Components 中的反序列化漏洞 - 原型链污染作为 RCE 原语 - Next.js Server Actions 的利用 - Node.js 环境中的后渗透技术 - 安全的实验室环境恢复方法论 **关键词:** `RCE` · `Prototype Pollution` · `Deserialization` · `React` · `Next.js` · `Server Actions` · `CVE-2025-55182` ## 作者 **Annais Molina (devianntsec)** — 安全研究员 | 网络安全硕士 (UCAM) [![GitHub](https://img.shields.io/badge/GitHub-@devianntsec-181717?style=flat-square&logo=github)](https://github.com/devianntsec) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Annais%20Molina-0077B5?style=flat-square&logo=linkedin)](https://linkedin.com/in/annais-molina-fuentes) [![博客](https://img.shields.io/badge/Blog-deviannt.com-FF5722?style=flat-square&logo=hashnode)](https://blog.deviannt.com) [![电子邮件](https://img.shields.io/badge/Email-me%40deviannt.com-D14836?style=flat-square&logo=gmail)](mailto:me@deviannt.com) ## 致谢 - [**@zack0x01**](https://github.com/zack0x01) — 原始易受攻击应用程序 - [**Lachlan Davidson (Carapace)**](https://github.com/assetnote) — 原始漏洞发现与负责任的披露 - [**AssetNote**](https://github.com/assetnote) — react2shell-scanner 检测工具 - [**Moritz Sanft**](https://github.com/moritz-sanft) — 首个可运行的公开 PoC(披露后约 30 小时) - [**maple3142**](https://gist.github.com/maple3142) — 原始报告者的公开 PoC(2025 年 12 月 5 日) ## 许可证 MIT License — 详见 [LICENSE](LICENSE) ## 法律免责声明 本代码库**仅用于教育和安全研究目的**,为学术硕士论文的一部分。所有测试均在无网络暴露的隔离虚拟机上进行。请仅在您拥有或获得明确书面授权进行测试的系统上使用。对系统进行未经授权的使用是非法的,可能导致刑事起诉。
© 2026 Annais Molina · 网络安全硕士论文
UCAM Universidad Católica San Antonio de Murcia · Campus Internacional de Ciberseguridad
标签:CISA项目, CVE-2025-55182, CVSS 10.0, MITM代理, Python, RCE, React Flight协议, React Server Components, Web安全, XXE攻击, 不安全反序列化, 交互式Shell, 原型污染, 原型链污染, 子进程执行, 安全实验室, 应用安全, 情报收集, 攻击模块, 数据展示, 数据窃取, 无后门, 服务器端请求伪造, 漏洞利用框架, 漏洞研究, 环境变量提取, 硕士学位论文, 红队, 编程工具, 网络安全, 蓝队分析, 远程代码执行, 逆向Shell, 逆向工具, 隐私保护