CORS Misconfiguration Testing
CORS misconfigurations allow attacker-controlled origins to make authenticated cross-origin requests to an API. When Access-Control-Allow-Origin reflects an attacker-supplied origin and Access-Control-Allow-Credentials: true is present, a malicious page can read API responses using the victim's session cookies. Detection confirms the misconfiguration exists — impact assessment determines whether sensitive data is accessible through the affected endpoints.
Reflected Origin Test
Send an arbitrary Origin header and check whether it is reflected in the response. This is the most common CORS misconfiguration:
access-control-allow-origin: https://attacker.com access-control-allow-credentials: true
Reflected origin with credentials allowed is a confirmed exploitable misconfiguration. Any origin can read API responses using the victim's cookies — no restriction is applied. This enables cross-origin reading of profile data, tokens, and other authenticated API responses.
Null Origin Test
Some applications trust a null origin for legacy compatibility. Sandboxed iframes can send null origins, making this exploitable:
access-control-allow-origin: null access-control-allow-credentials: true
Subdomain Trust Test
Some applications restrict CORS to subdomains of their own domain. If any subdomain is compromised or has XSS, it can be used to make credentialed cross-origin requests:
access-control-allow-origin: https://evil.example.com access-control-allow-credentials: true
A suffix match bypass like example.com.attacker.com being trusted indicates the application uses a vulnerable contains or endsWith check rather than exact origin matching.
Wildcard Without Credentials
A wildcard Access-Control-Allow-Origin: * without Allow-Credentials is not directly exploitable for authenticated requests but confirms the API returns data to any origin — useful for unauthenticated data gathering:
access-control-allow-origin: *
Test Multiple Endpoints
CORS configuration often differs between endpoints. The main domain may be hardened while API and auth endpoints are not. Test all discovered API paths:
/api/v1/user: access-control-allow-origin: https://attacker.com /api/v1/profile: access-control-allow-origin: * /api/v1/orders: /graphql: access-control-allow-origin: https://attacker.com
References
-
PortSwigger — CORSportswigger.net/web-security/cors (opens in new tab)
CORS misconfiguration types and exploitability conditions
-
CORS specification and access-control-allow-credentials behavior
Was this helpful?
Your feedback helps improve this page.