Cross-Origin Resource Sharing (CORS) enables servers to define who can access their assets from external sources. Misconfigurations allow attackers to steal sensitive data from authenticated users.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HackTricks-wiki/hacktricks/llms.txt
Use this file to discover all available pages before exploring further.
CORS Headers Reference
| Header | Purpose |
|---|---|
Access-Control-Allow-Origin | Specifies allowed origins (can be *, null, or specific origin) |
Access-Control-Allow-Credentials | If true, allows sending cookies with cross-origin requests |
Access-Control-Allow-Methods | HTTP methods permitted in the actual request |
Access-Control-Allow-Headers | Request headers allowed |
Access-Control-Max-Age | Preflight response cache duration |
Access-Control-Expose-Headers | Headers exposed to JavaScript |
Exploitable Misconfigurations
Reflected Origin
When the server dynamically reflects theOrigin header value in Access-Control-Allow-Origin:
Null Origin Exploit
Some applications whitelistnull origin for local development. Use a sandboxed iframe to generate null origin:
Regex Bypass Techniques
XSS on Whitelisted Subdomain
Ifsub.requester.com is whitelisted and vulnerable to XSS:
Server-Side Cache Poisoning
If the server doesn’t sanitize theOrigin header for illegal characters, inject HTTP headers via \r\n (0x0d 0x0a):
Client-Side Cache Poisoning
If the page reflects a custom header without encoding:Vary: Origin), subsequent visits serve the poisoned response.
XSSI / JSONP Bypass
DNS Rebinding Attacks
DNS Rebinding via TTL
- Victim visits attacker’s page
- Attacker changes DNS A record (TTL=0) to internal IP
- Victim’s browser re-resolves DNS and now same-origin with internal service
- Attacker can read internal service responses
DNS Rebinding via Multiple IPs
- Set two A records: attacker IP +
0.0.0.0(Linux/macOS) - First request goes to attacker IP (serves payload)
- Attacker blocks their IP with iptables
- Second request resolves to
0.0.0.0(localhost) - Browser treats as same origin
DNS Rebinding over DoH (DNS-over-HTTPS)
Some DoH providers (NextDNS) replace private/loopback answers with
0.0.0.0, but Linux/macOS still route to local services.Protections Against DNS Rebinding
- Use TLS in internal services
- Require authentication to access data
- Validate the
Hostheader on internal services - Implement HTTPS with valid certificates
Tools
- CORScanner
- Corsy
- CorsOne
- theftfuzzer
- Burp Collaborator Everywhere (Burp extension)