Loading...
Loading...
Cross-Origin Resource Sharing (CORS) controls which domains can access your API resources via the browser.
The "Wildcard Exploit": Setting `Access-Control-Allow-Origin: *` allows ANY site to read your API response. If you also allow `Access-Control-Allow-Credentials: true`, you have created a Critical vulnerability. Attackers can read private user data (emails, settings) by hosting a malicious site that queries your API on behalf of the logged-in user.
Never use `*` with `Credentials: true`. The browser will actually block this combo, so developers often accidentally write code that reflects the `Origin` header, which is just as bad. Explicitly whitelist trusted domains.
Probe the endpoint with a custom `Origin` header and inspect the response. Three red flags: `Access-Control-Allow-Origin: *` plus `Access-Control-Allow-Credentials: true` (browser will block but the misconfig proves reflection logic is wrong), origin echo (ACAO equals whatever you send), and a permissive regex that accepts unexpected subdomains.
curl -sI -H "Origin: https://attacker.com" https://api.yourdomain.com/user | grep -i access-controlcurl -sI -H "Origin: null" https://api.yourdomain.com/user | grep -i access-controlcurl -sI -H "Origin: https://yourdomain.com.attacker.com" https://api.yourdomain.com/userIt is equivalent to `Access-Control-Allow-Origin: *` with credentials - any attacker-controlled site can make authenticated requests on behalf of the logged-in user and read the response. The only safe pattern is an explicit allowlist of exact origin strings.
Only for truly public endpoints that never serve user-specific data and never require credentials. Public font CDNs, map tiles, and open-data APIs qualify. Anything behind authentication does not.
No. CORS is a browser-enforced opt-in to relax the Same-Origin Policy. Non-browser clients (curl, Postman, server-to-server) ignore it entirely. API authentication, authorization, and input validation remain mandatory.
Applied the configuration change? Run a live scan to confirm the vulnerability is patched.