← Learn

CORS misconfiguration: when "Access-Control-Allow-Origin: *" is dangerous

A wide-open CORS policy can let any website read authenticated responses from your API. Here is when a wildcard is fine and when it leaks data.

CORS controls which other websites' JavaScript may read responses from your API. AI builders often set it wide open to "make the error go away," which can expose authenticated data.

When a wildcard is fine — and when it isn't

Access-Control-Allow-Origin: * is acceptable for public, unauthenticated endpoints. It becomes dangerous when combined with credentials: if you reflect the request's Origin (or send *) and set Access-Control-Allow-Credentials: true, any malicious site can make a logged-in user's browser fetch their private data and read it.

The fix

  1. Never combine a wildcard / reflected origin with Allow-Credentials: true.
  2. Maintain an explicit allowlist of origins you trust and echo back only those.
  3. For public read-only data with no cookies, a plain * without credentials is fine.

→ Scan your app free

FAQ

Is Access-Control-Allow-Origin: * always bad?
No. It is fine for public, unauthenticated endpoints. It is dangerous when paired with Access-Control-Allow-Credentials: true, which lets other sites read logged-in users’ responses.

How should I configure CORS for an app with logins?
Use an explicit allowlist of trusted origins and reflect only those. Do not send a wildcard or blindly reflect the Origin header when credentials are allowed.

Related questions

Check your own app
Free passive scan, ~10 seconds, no login.