
AWS Organization-wide detection toolkit for CVE-2025-55182 & CVE-2025-66478 (React Server Components / Next.js RCE vulnerabilities)
CVE-2025-55182 および CVE-2025-66478 向け AWS 組織全体検出ツールキット
⚠️ 重要な免責事項 - ご使用前にお読みください
このツールキットは、本番 AWS 環境ではテストされていません。
インフラストラクチャの制約により、このプロジェクトはコードレビュー、静的解析、およびドキュメント検証のみを通じて開発および検証されました。アクティブな GuardDuty、WAF、EventBridge、または CloudTrail サービスを備えた実際の AWS 環境にデプロイまたはテストされていません。
これが意味すること:
コンポーネント 状況 Python スキャナーロジック ✅ コードレビュー済み、Snyk 検証済み Terraform 構文 ✅ 検証済み、未適用 IAM ポリシー ⚠️ 環境に応じた調整が必要な可能性があります EventBridge ルール ⚠️ AWS ドキュメントに基づく検出パターン WAF ルール ⚠️ 正規表現パターンは実際のトラフィックに対してテストされていません Athena クエリ ⚠️ スキーマの前提条件は変更が必要な可能性があります 推奨事項:
- まず非本番アカウントにデプロイする - すべてのコンポーネントをサンドボックス環境でテストしてください
- IAM ポリシーを注意深く確認する - 組織の要件に合わせて権限を調整してください
- Terraform プランを検証する -
terraform planを実行してから適用してください- EventBridge パターンをテストする - 検出タイプ文字列が GuardDuty 出力と一致することを確認してください
- CloudWatch ログを監視する - デプロイ後にエラーがないか確認してください
責任:
このソフトウェアは「現状のまま」提供され、いかなる種類の保証もありません。著者は、このツールキットの使用により発生したいかなる損害、セキュリティインシデント、または AWS 費用についても責任を負いません。ご自身の責任でご使用ください。
このツールキットのデプロイとテストに成功した場合は、コミュニティのために結果をご提供いただけると幸いです。
AWS 環境全体で React2Shell の悪用試行を検出するための包括的なセキュリティツールキットです。このツールキットは、React Server Components の重大な RCE 脆弱性に対するリアルタイム検出、脅威ハンティング機能、および自動応答を提供します。
__proto__:then の操作により、process.mainModule.require('child_process').execSync() を介した任意のコード実行が可能## 前提条件
### 必要な権限```
# Minimum IAM permissions for the detection script
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudtrail:LookupEvents",
"logs:StartQuery",
"logs:GetQueryResults",
"guardduty:ListDetectors",
"guardduty:ListFindings",
"guardduty:GetFindings",
"guardduty:CreateThreatIntelSet",
"guardduty:UpdateThreatIntelSet",
"guardduty:ListThreatIntelSets",
"guardduty:GetThreatIntelSet",
"s3:PutObject",
"s3:GetObject",
"sts:GetCallerIdentity",
"sts:AssumeRole"
],
"Resource": "*"
}
]
}
# For Security Hub integration, add:
"securityhub:BatchImportFindings"
# For SNS alerting, add:
"sns:Publish"
# For organization-wide scanning, add:
"organizations:ListAccounts"
| ソフトウェア | バージョン |
|---|
cd React2Shell_Hunter
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
### ステップ 2: AWS 認証情報を設定する```bash
# Option A: Use AWS CLI profile
aws configure --profile security-scanner
# Option B: Export environment variables
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="us-east-1"
# Option C: Use IAM role (recommended for EC2/Lambda)
# Attach appropriate IAM role to your compute resource
aws sts get-caller-identity
python -c "import boto3, yaml; print('Dependencies OK')"
python -c " import yaml with open('config/iocs.yaml') as f: iocs = yaml.safe_load(f) print(f'Loaded {len(iocs["network_iocs"]["malicious_ips"])} malicious IPs') "
## クイックスタート
### 現在のアカウントをスキャン(過去24時間)```bash
python src/react2shell_detector.py --hours 24
期待される出力:``` 2025-12-06 10:00:00 - React2ShellDetector - INFO - ============================================================ 2025-12-06 10:00:00 - React2ShellDetector - INFO - React2Shell IOC Detection Script 2025-12-06 10:00:00 - React2ShellDetector - INFO - CVE-2025-55182 & CVE-2025-66478 2025-12-06 10:00:00 - React2ShellDetector - INFO - ============================================================ 2025-12-06 10:00:00 - React2ShellDetector - INFO - Starting single account scan... 2025-12-06 10:00:00 - React2ShellDetector - INFO - Analyzing CloudTrail logs... 2025-12-06 10:00:05 - React2ShellDetector - INFO - Checking GuardDuty findings...
Total findings: 0 CRITICAL: 0 HIGH: 0 MEDIUM: 0
### 本番フルスキャン```bash
python src/react2shell_detector.py \
--organization \
--role-name SecurityAuditRole \
--security-hub \
--guardduty-bucket my-threat-intel-bucket-12345 \
--vpc-log-group /aws/vpc/flowlogs \
--waf-log-group aws-waf-logs-react2shell \
--sns-topic arn:aws:sns:us-east-1:123456789012:security-alerts \
--output json \
--output-file findings-$(date +%Y%m%d).json \
--hours 72
GuardDutyではカスタム検出ルールを作成することはできません。
GuardDutyはMLモデルと脅威インテリジェンスを使用して検出結果を生成します。React2Shellを検出するには:
MaliciousIPCaller.Custom の検出結果を生成### EventBridge ルールパターン
Terraform は7つの特定のEventBridgeルールを作成します:
| ルール | 検出タイプパターン | 重大度 |
|------|---------------------|----------|
| `react2shell-malicious-ip-caller` | `MaliciousIPCaller.Custom` | CRITICAL |
| `react2shell-credential-exfiltration` | `InstanceCredentialExfiltration.*` | CRITICAL |
| `react2shell-dns-exfiltration` | `DNSDataExfiltration` | HIGH |
| `react2shell-cryptocurrency-mining` | `CryptoCurrency:*` | HIGH |
| `react2shell-unusual-network-ports` | `NetworkPortUnusual` | MEDIUM |
| `react2shell-malicious-domain` | `MaliciousDomainRequest.*` | HIGH |
| `react2shell-high-severity-catchall` | 重大度 >= 7 | VARIES |
### WAF 保護レイヤー
WAF WebACL は優先順位に従って9つのルールを実装します:
| 優先順位 | ルール | アクション | 検出内容 |
|----------|------|--------|-----------------|
| 1 | 悪意のあるIPのブロック | BLOCK | 既知の9つのC2 IPからの接続 |
| 2 | Next-Action ヘッダー値 | BLOCK | `next-action` ヘッダーに含まれる `$ACTION` または `__proto__` パターン |
| 3 | RSC-Action-ID ヘッダー値 | BLOCK | `rsc-action-id` ヘッダーに含まれる `$ACTION` または `__proto__` パターン |
| 4 | プロトタイプ汚染 | BLOCK | ボディ内の `__proto__` または `constructor.prototype` |
| 5 | RCE パターン | BLOCK | `process.mainModule.require`, `child_process`, `execSync` |
| 6 | ACTION パラメータ | BLOCK | POSTボディ内の `$ACTION_0:0` または `$ACTION_REF` |
| 7 | 不審なUser-Agent | COUNT | `Go-http-client`, `Assetnote`, `python-requests` |
| 8 | AWS既知の不正インプット | INHERIT | AWS管理ルールグループ |
| 9 | AWS共通ルールセット | INHERIT | AWS管理ルールグループ |
> **注記**: ルール2と3は、複数の `byte_match_statement` チェックを含む `or_statement` を使用して、悪意のあるヘッダー値(ヘッダーの存在だけでなく)を検出します。AWS WAFはヘッダーマッチングで正規表現をサポートしていないため、各パターンには個別のステートメントが必要です。WAFの要件に従い、ヘッダー名は小文字で記述されます。
---
## コンポーネントリファレンス
### プロジェクト構造```
React2Shell_Hunter/
├── config/
│ └── iocs.yaml # IOC database (IPs, domains, patterns) - 452 lines
├── src/
│ └── react2shell_detector.py # Main detection script - 1141 lines
├── terraform/
│ ├── guardduty.tf # GuardDuty + ThreatIntelSet + S3 - 405 lines
│ ├── eventbridge_rules.tf # 7 EventBridge rules - 533 lines
│ └── waf_rules.tf # WAF WebACL with 9 rules - 681 lines
├── lambda/
│ └── ioc_scanner/
│ └── handler.py # Real-time Lambda scanner - 381 lines
├── athena_queries/
│ └── detection_queries.sql # 18 threat hunting queries - 483 lines
├── tests/
│ ├── __init__.py # Test package init
│ ├── conftest.py # Pytest fixtures (project_root, ioc_config, etc.)
│ ├── test_ioc_matching.py # IOC pattern validation tests
│ ├── test_terraform.py # Terraform configuration validation
│ └── test_waf_patterns.py # WAF regex pattern tests
├── docs/
│ ├── THREAT_INTELLIGENCE_REPORT.md
│ └── GUARDDUTY_EVENTBRIDGE_SETUP_GUIDE.md
├── requirements.txt # Python dependencies (boto3, pyyaml, pytest, python-hcl2)
├── README.md
└── CLAUDE.md
cd terraform
terraform init
terraform plan
-var="threat_intel_bucket=react2shell-threat-intel-$(aws sts get-caller-identity --query Account --output text)"
-var="enable_guardduty=true"
-var="enable_waf=true"
-var="waf_scope=REGIONAL"
terraform apply
-var="threat_intel_bucket=react2shell-threat-intel-$(aws sts get-caller-identity --query Account --output text)"
**Terraform変数:**
| 変数 | 必須 | デフォルト | 説明 |
|----------|----------|---------|-------------|
| `threat_intel_bucket` | YES | - | 脅威インテルファイル用のS3バケット名 |
| `enable_guardduty` | no | true | GuardDuty検出器を有効化 |
| `enable_waf` | no | true | WAF WebACLを作成 |
| `waf_scope` | no | REGIONAL | `REGIONAL` または `CLOUDFRONT` |
| `block_mode` | no | BLOCK | `BLOCK` または `COUNT` |
| `enable_lambda_automation` | no | false | 自動応答のためのLambdaを有効化 |
### ステップ2: WAFをリソースに関連付ける
WAF WebACLは、以下のリソースに関連付ける必要があります:```bash
# Associate with ALB
aws wafv2 associate-web-acl \
--web-acl-arn $(terraform output -raw web_acl_arn) \
--resource-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/my-alb/1234567890
# Associate with API Gateway
aws wafv2 associate-web-acl \
--web-acl-arn $(terraform output -raw web_acl_arn) \
--resource-arn arn:aws:apigateway:us-east-1::/restapis/abc123/stages/prod
SNS_TOPIC=$(terraform output -raw sns_topic_arn)
aws sns subscribe
--topic-arn $SNS_TOPIC
--protocol email
--notification-endpoint [email protected]
aws sns subscribe
--topic-arn $SNS_TOPIC
--protocol lambda
--notification-endpoint arn:aws:lambda:us-east-1:123456789012:function:slack-notifier
### ステップ4: Athena テーブルを作成```bash
# Open Athena console or use AWS CLI
# Run the CREATE TABLE statements from athena_queries/detection_queries.sql
# CloudTrail table
aws athena start-query-execution \
--query-string "CREATE EXTERNAL TABLE cloudtrail_logs ..." \
--work-group primary \
--query-execution-context Database=default
| ポート | 用途 |
|---|---|
| 652 | PowerShellステージャ |
| 2045 | カスタムC2 |
| 8000, 8080 | 代替HTTP C2 |
| 12000, 45178 | カスタムC2 |
| 3333, 5555, 14433, 14444 |
aws guardduty list-detectors
aws guardduty create-detector --enable
terraform apply -var="enable_guardduty=true"
#### "メンバーアカウントでロールの引き受けに失敗しました"```bash
# Verify role exists in target account
aws iam get-role --role-name SecurityAuditRole
# Verify trust policy allows your account
aws iam get-role --role-name SecurityAuditRole --query 'Role.AssumeRolePolicyDocument'
# Test role assumption
aws sts assume-role \
--role-arn arn:aws:iam::TARGET_ACCOUNT:role/SecurityAuditRole \
--role-session-name test
DETECTOR_ID=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text) aws guardduty list-threat-intel-sets --detector-id $DETECTOR_ID
aws s3api get-bucket-policy --bucket your-threat-intel-bucket
aws s3 cp s3://your-bucket/threat-intel/react2shell-ips.txt -
#### "WAFルールがブロックしていない"```bash
# Check if WebACL is associated
aws wafv2 list-resources-for-web-acl \
--web-acl-arn $(terraform output -raw web_acl_arn)
# Check sampled requests
aws wafv2 get-sampled-requests \
--web-acl-arn $(terraform output -raw web_acl_arn) \
--rule-metric-name React2Shell-Malicious-IP-Blocked \
--scope REGIONAL \
--time-window StartTime=2025-12-06T00:00:00Z,EndTime=2025-12-06T23:59:59Z \
--max-items 10
DETECTOR_ID=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text)
aws guardduty create-sample-findings
--detector-id $DETECTOR_ID
--finding-types "UnauthorizedAccess:IAMUser/MaliciousIPCaller.Custom"
aws cloudwatch get-metric-statistics
--namespace AWS/Events
--metric-name Invocations
--dimensions Name=RuleName,Value=react2shell-malicious-ip-caller
--start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ)
--period 300
--statistics Sum
## よくある質問
### Q: これはパッチ適用を置き換えるものですか?
**いいえ。** これは検出ツールキットであり、防止ソリューションではありません。以下にパッチを適用する必要があります:
- React: 19.0.1、19.1.2、または19.2.1
- Next.js: 15.0.5、15.1.9、15.2.6、15.3.6、15.4.8、15.5.7、または16.0.7
### Q: これはすべてのReact2Shell攻撃を検出しますか?
**100%の検出はありません。** このツールキットは以下を検出します:
- 既知のC2 IPへの接続(攻撃者が新しいIPを使用した場合は検出されません)
- 既知のペイロードパターン(攻撃者が難読化した場合、WAFを回避する可能性があります)
- 侵害後行動(認証情報の窃取、横方向の移動)
### Q: スキャナーはどのくらいの頻度で実行すべきですか?
推奨スケジュール:
- **継続的**: GuardDuty + EventBridge(リアルタイム)
- **毎時**: `--hours 1` オプション付きのPythonスクリプト
- **毎日**: Athena完全脅威ハントクエリ
### Q: 新しいIOCを追加するにはどうすればよいですか?
`config/iocs.yaml` を編集し、適切なセクションに追加します:```yaml
network_iocs:
malicious_ips:
- ip: "NEW.IP.ADDRESS.HERE"
port: 8080
context: "Description"
confidence: high
source: "Your source"
次に、ThreatIntelSetを更新します:```bash python src/react2shell_detector.py --guardduty-bucket your-bucket
---
## テストの実行```bash
# Install test dependencies
pip install -r requirements.txt
# Run all tests
pytest tests/ -v
# Run specific test categories
pytest tests/test_terraform.py -v # Terraform validation
pytest tests/test_ioc_matching.py -v # IOC pattern tests
pytest tests/test_waf_patterns.py -v # WAF regex tests
# Run with coverage
pytest tests/ --cov=src --cov-report=html
免責事項: このツールキットは防御的なセキュリティ目的のみに使用してください。システムをスキャンする前に適切な許可を得ていることを確認してください。
| 目的 |
|---|
| Python | 3.9+ | 検出スクリプトの実行環境 |
| Terraform | 1.0+ | インフラストラクチャのデプロイ |
| AWS CLI | 2.x | AWS認証 |
| boto3 | 1.34+ | Python用AWS SDK |
| クラス | 目的 | 主要メソッド |
|---|
IOCLoader | YAMLからIOCを読み込む | get_malicious_ips(), get_suspicious_ports(), get_malicious_domains() |
CloudTrailAnalyzer | APIベースのIOCを検出する | analyze_recent_events(hours) |
VPCFlowLogAnalyzer | ネットワークIOCを検出する | analyze_flow_logs(log_group, hours) |
GuardDutyManager | 脅威インテリジェンスを管理する | create_threat_intel_set(bucket), get_relevant_findings(hours) |
WAFLogAnalyzer | HTTP IOCを検出する | analyze_waf_logs(log_group, hours) |
OrganizationScanner | クロスアカウントスキャン | scan_organization(hours, role_name) |
SecurityHubReporter | 検出結果を取り込む | import_findings(findings) |
SNSAlerter | アラートを送信する | send_alert(findings) |
| 引数 | 型 | デフォルト | 説明 |
|---|
--config | string | config/iocs.yaml | IOC設定ファイルへのパス |
--hours | int | 24 | 分析するログの時間数 |
--organization | flag | false | AWS組織全体をスキャン |
--role-name | string | OrganizationAccountAccessRole | メンバーアカウントで引き受けるロール |
--sns-topic | string | none | アラート用のSNSトピックARN |
--security-hub | flag | false | 検出結果をSecurity Hubに取り込む |
--guardduty-bucket | string | none | GuardDuty脅威インテル用のS3バケット |
--vpc-log-group | string | none | VPCフローログのCloudWatchロググループ |
--waf-log-group | string | none | WAFログのCloudWatchロググループ |
--output | enum | text | 出力形式: json, text, csv |
--output-file | string | none | 出力ファイルパス |
--debug | flag | false | デバッグログを有効化 |
| IPアドレス | ポート | 信頼度 | コンテキスト | ソース |
|---|
| 93.123.109.247 | 8000 | HIGH | プライマリC2サーバ | Datadog |
| 45.77.33.136 | 8080 | HIGH | プライマリC2サーバ | Datadog |
| 194.246.84.13 | 2045 | HIGH | プライマリC2サーバ | Datadog |
| 141.11.240.103 | 45178 | HIGH | プライマリC2サーバ | Datadog |
| 23.235.188.3 | 652 | HIGH | PowerShellステージャ | GreyNoise |
| 46.36.37.85 | 12000 | HIGH | ペイロードステージング | GreyNoise |
| 144.202.115.234 | 80 | MEDIUM | ペイロードホスティング | Datadog |
| 162.215.170.26 | 3000 | MEDIUM | セカンダリペイロード | GreyNoise |
| 45.32.158.54 | - | MEDIUM | スキャナ | GreyNoise |
| ドメイン | カテゴリ | 信頼度 |
|---|
| ceye.io | DNS外部漏洩 | HIGH |
| dnslog.cn | DNS外部漏洩 | HIGH |
| *.oastify.com | Burp Collaborator | MEDIUM |
| sapo.shk0x.net | C2 | HIGH |
| xwpoogfunv.zaza.eu.org | C2 | HIGH |
| *.c3pool.com | クリプトマイニング | HIGH |
| クリプトマイニング |
| パターン | 重大度 | 説明 |
|---|
next-action: * | CRITICAL | RSCエクスプロイトヘッダ(WAF内では小文字) |
rsc-action-id: * | CRITICAL | RSCアクション識別子(WAF内では小文字) |
$ACTION_0:0 | CRITICAL | RSCアクションパラメータ |
__proto__:then | CRITICAL | プロトタイプ汚染 |
process.mainModule.require | CRITICAL | Node.js RCE |
child_process | CRITICAL | コマンド実行 |
Go-http-client/1.1 | MEDIUM | スキャナユーザエージェント |