
CVE-2025-55182 & CVE-2025-66478 (React Server Components / Next.js RCE 취약점)을 위한 AWS 조직 전체 탐지 도구 키트
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 서버 컴포넌트 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` | Severity >= 7 | VARIES |
### WAF 보호 계층
WAF WebACL은 우선순위에 따라 9개의 규칙을 구현합니다:
| 우선순위 | 규칙 | 동작 | 탐지 대상 |
|----------|------|--------|-----------------|
| 1 | Block Malicious IPs | BLOCK | 알려진 9개의 C2 IP로부터의 연결 |
| 2 | Next-Action Header Values | BLOCK | `$ACTION` 또는 `__proto__` 패턴을 포함하는 `next-action` 헤더 |
| 3 | RSC-Action-ID Header Values | BLOCK | `$ACTION` 또는 `__proto__` 패턴을 포함하는 `rsc-action-id` 헤더 |
| 4 | Prototype Pollution | BLOCK | 본문 내 `__proto__` 또는 `constructor.prototype` |
| 5 | RCE Patterns | BLOCK | `process.mainModule.require`, `child_process`, `execSync` |
| 6 | ACTION Parameter | BLOCK | POST 본문 내 `$ACTION_0:0` 또는 `$ACTION_REF` |
| 7 | Suspicious User-Agents | COUNT | `Go-http-client`, `Assetnote`, `python-requests` |
| 8 | AWS Known Bad Inputs | INHERIT | AWS 관리형 규칙 그룹 |
| 9 | AWS Common Rule Set | 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` | 예 | - | 위협 인텔리전스 파일을 위한 S3 버킷 이름 |
| `enable_guardduty` | 아니오 | true | GuardDuty 탐지기 활성화 |
| `enable_waf` | 아니오 | true | WAF WebACL 생성 |
| `waf_scope` | 아니오 | REGIONAL | `REGIONAL` 또는 `CLOUDFRONT` |
| `block_mode` | 아니오 | BLOCK | `BLOCK` 또는 `COUNT` |
| `enable_lambda_automation` | 아니오 | 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
### Step 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 |
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
---
## FAQ
### 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 |
| Class | 목적 | 주요 메서드 |
|---|
IOCLoader | YAML에서 IOCs 로드 | get_malicious_ips(), get_suspicious_ports(), get_malicious_domains() |
CloudTrailAnalyzer | API 기반 IOCs 탐지 | analyze_recent_events(hours) |
VPCFlowLogAnalyzer | 네트워크 IOCs 탐지 | analyze_flow_logs(log_group, hours) |
GuardDutyManager | 위협 인텔리전스 관리 | create_threat_intel_set(bucket), get_relevant_findings(hours) |
WAFLogAnalyzer | HTTP IOCs 탐지 | 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 Flow Logs 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 | 높음 | 기본 C2 서버 | Datadog |
| 45.77.33.136 | 8080 | 높음 | 기본 C2 서버 | Datadog |
| 194.246.84.13 | 2045 | 높음 | 기본 C2 서버 | Datadog |
| 141.11.240.103 | 45178 | 높음 | 기본 C2 서버 | Datadog |
| 23.235.188.3 | 652 | 높음 | PowerShell 스테이저 | GreyNoise |
| 46.36.37.85 | 12000 | 높음 | 페이로드 스테이징 | GreyNoise |
| 144.202.115.234 | 80 | 중간 | 페이로드 호스팅 | Datadog |
| 162.215.170.26 | 3000 | 중간 | 보조 페이로드 | GreyNoise |
| 45.32.158.54 | - | 중간 | 스캐너 | GreyNoise |
| 도메인 | 카테고리 | 신뢰도 |
|---|
| ceye.io | DNS 유출 | 높음 |
| dnslog.cn | DNS 유출 | 높음 |
| *.oastify.com | Burp Collaborator | 중간 |
| sapo.shk0x.net | C2 | 높음 |
| xwpoogfunv.zaza.eu.org | C2 | 높음 |
| *.c3pool.com | 암호화폐 채굴 | 높음 |
| 3333, 5555, 14433, 14444 |
| 암호화폐 채굴 |
| 패턴 | 심각도 | 설명 |
|---|
next-action: * | 심각 | RSC 익스플로잇 헤더 (WAF에서 소문자) |
rsc-action-id: * | 심각 | RSC 액션 식별자 (WAF에서 소문자) |
$ACTION_0:0 | 심각 | RSC 액션 매개변수 |
__proto__:then | 심각 | 프로토타입 오염 |
process.mainModule.require | 심각 | Node.js RCE |
child_process | 심각 | 명령 실행 |
Go-http-client/1.1 | 중간 | 스캐너 사용자 에이전트 |