
أداة كشف على مستوى مؤسسة AWS بالكامل لثغرات CVE-2025-55182 وCVE-2025-66478 (ثغرات RCE في React Server Components / Next.js)
مجموعة أدوات كشف على مستوى مؤسسة AWS لثغرات CVE-2025-55182 و CVE-2025-66478
⚠️ إخلاء مسؤولية مهم - يُرجى القراءة قبل الاستخدام
لم يتم اختبار هذه المجموعة في بيئة AWS إنتاجية.
بسبب قيود البنية التحتية، تم تطوير هذا المشروع والتحقق منه فقط من خلال مراجعة الكود، والتحليل الثابت، والتحقق من التوثيق. لم يتم نشره أو اختباره على بيئة AWS حية تحتوي على خدمات GuardDuty أو WAF أو EventBridge أو CloudTrail نشطة.
ماذا يعني هذا بالنسبة لك:
المكوّن الحالة منطق الماسح الضوئي بلغة Python ✅ تمت مراجعة الكود والتحقق منه عبر Snyk صيغة Terraform ✅ تم التحقق منها ولم يتم تطبيقها سياسات IAM ⚠️ قد تتطلب تعديلًا حسب بيئتك قواعد EventBridge ⚠️ أنماط النتائج مستندة إلى توثيق AWS قواعد WAF ⚠️ أنماط Regex غير مختبرة على الحركة المباشرة استعلامات Athena ⚠️ افتراضات المخطط قد تحتاج إلى تعديل التوصيات:
- انشر في حساب غير إنتاجي أولاً - اختبر جميع المكونات في بيئة تجريبية (sandbox)
- راجع سياسات IAM بعناية - اضبط الصلاحيات لتتوافق مع متطلبات مؤسستك
- تحقق من خطط Terraform - شغّل
terraform planوراجعها قبل التطبيق- اختبر أنماط EventBridge - تحقق من أن سلاسل نوع النتائج تطابق مخرجات GuardDuty لديك
- راقب سجلات CloudWatch - تحقق من وجود أخطاء بعد النشر
المسؤولية:
يتم توفير هذا البرنامج "كما هو" دون أي ضمان من أي نوع. لا يتحمل المؤلفون أي مسؤولية عن أي ضرر أو حوادث أمنية أو تكاليف AWS المتكبدة نتيجة استخدام هذه المجموعة. استخدمها على مسؤوليتك الخاصة.
إذا قمت بنشر واختبار هذه المجموعة بنجاح، فيُرجى التفكير في المساهمة بنتائجك لتحسينها لصالح المجتمع.
مجموعة أدوات أمنية شاملة لكشف محاولات استغلال React2Shell عبر بيئات AWS. توفر هذه المجموعة كشفًا في الوقت الفعلي، وقدرات بحث استباقي عن التهديدات، واستجابة آلية لثغرة RCE الحرجة في React Server Components.
__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 نماذج التعلم الآلي ومعلومات التهديدات لتوليد النتائج. للكشف عن 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
تنفّذ WebACL الخاصة بـ WAF 9 قواعد بترتيب الأولوية:
| الأولوية | القاعدة | الإجراء | ما الذي يكتشفه |
|----------|------|--------|-----------------|
| 1 | حظر عناوين IP الخبيثة | BLOCK | اتصالات من 9 عناوين C2 معروفة |
| 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 | وجود `$ACTION_0:0` أو `$ACTION_REF` في جسم POST |
| 7 | وكلاء المستخدم المشبوهون | COUNT | `Go-http-client`, `Assetnote`, `python-requests` |
| 8 | المدخلات الضارة المعروفة من AWS | INHERIT | مجموعة قواعد مُدارة من AWS |
| 9 | مجموعة قواعد AWS الشائعة | INHERIT | مجموعة قواعد مُدارة من AWS |
> **ملاحظة**: تستخدم القاعدتان 2 و3 `or_statement` مع عدة فحوصات `byte_match_statement` لاكتشاف قيم ترويسات ضارة (وليس مجرد وجود الترويسة). لا يدعم AWS WAF التعبيرات النمطية (regex) في مطابقة الترويسات، لذلك يتطلب كل نمط بيانًا منفصلًا. أسماء الترويسات تكون بأحرف صغيرة كما يتطلب 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 | إنشاء WebACL من WAF |
| `waf_scope` | لا | REGIONAL | `REGIONAL` أو `CLOUDFRONT` |
| `block_mode` | لا | BLOCK | `BLOCK` أو `COUNT` |
| `enable_lambda_automation` | لا | false | تفعيل Lambda للاستجابة الآلية |
### الخطوة 2: ربط WAF بالموارد
يجب ربط WebACL الخاص بـ WAF بمواردك:```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 stager |
| 2045 | C2 مخصص |
| 8000, 8080 | C2 عبر HTTP بديل |
| 12000, 45178 |
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
---
## الأسئلة الشائعة
### س: هل يحلّ هذا محل التصحيح؟
**لا.** هذه مجموعة أدوات كشف، وليست حلًا للحماية. يجب عليك التصحيح:
- 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
### س: هل سيكتشف هذا جميع هجمات React2Shell؟
**لا يوجد كشف مضمون 100%.** تكتشف هذه المجموعة:
- الاتصالات بعناوين C2 المعروفة (إذا استخدم المهاجم عناوين IP جديدة، فلن يتم اكتشافها)
- أنماط الحمولة المعروفة (إذا قام المهاجم بالتشويش، فقد يتجاوز جدار الحماية WAF)
- سلوك ما بعد الاستغلال (سرقة بيانات الاعتماد، الحركة الجانبية)
### س: كم مرة يجب أن أشغّل الماسح الضوئي؟
الجدول الزمني الموصى به:
- **مستمر**: GuardDuty + EventBridge (في الوقت الفعلي)
- **كل ساعة**: سكربت Python مع `--hours 1`
- **يوميًا**: استعلامات صيد التهديدات الكاملة في Athena
### س: كيف أضيف مؤشرات اختراق جديدة؟
عدّل `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+ | AWS SDK للغة Python |
| الفئة | الغرض | الأساليب الرئيسية |
|---|
IOCLoader | تحميل مؤشرات الاختراق (IOCs) من YAML | get_malicious_ips()، get_suspicious_ports()، get_malicious_domains() |
CloudTrailAnalyzer | كشف مؤشرات الاختراق المستندة إلى API | analyze_recent_events(hours) |
VPCFlowLogAnalyzer | كشف مؤشرات الاختراق الشبكية | analyze_flow_logs(log_group, hours) |
GuardDutyManager | إدارة معلومات التهديدات | create_threat_intel_set(bucket)، get_relevant_findings(hours) |
WAFLogAnalyzer | كشف مؤشرات اختراق HTTP | 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 | ARN موضوع SNS للتنبيهات |
--security-hub | flag | false | استيراد النتائج إلى Security Hub |
--guardduty-bucket | string | none | مخزن S3 لمعلومات تهديدات GuardDuty |
--vpc-log-group | string | none | مجموعة سجلات CloudWatch الخاصة بـ VPC Flow Logs |
--waf-log-group | string | none | مجموعة سجلات CloudWatch لسجلات WAF |
--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 Stager | 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 |
| C2 مخصص |
| 3333, 5555, 14433, 14444 | تعدين العملات الرقمية |
| النمط | الخطورة | الوصف |
|---|
next-action: * | CRITICAL | ترويسة استغلال RSC (بأحرف صغيرة في WAF) |
rsc-action-id: * | CRITICAL | معرّف إجراء RSC (بأحرف صغيرة في WAF) |
$ACTION_0:0 | CRITICAL | معامل إجراء RSC |
__proto__:then | CRITICAL | تلوث النموذج الأولي |
process.mainModule.require | CRITICAL | RCE في Node.js |
child_process | CRITICAL | تنفيذ أوامر |
Go-http-client/1.1 | MEDIUM | User-Agent لماسح ضوئي |