Tools / CORS policy
CORS policy checker
See how an endpoint responds to a cross-origin request and browser preflight, including whether it reflects arbitrary origins or allows credentials.
More free checks
Run a full security scan or speed test on your site, or try a related tool.
Related free tools
What it checks
- Cross-origin GET response headers for a non-credentialed probe origin.
- OPTIONS preflight response for a POST request with common headers.
- Allowed origin, methods, headers, credentials, and
Vary: Origin.
This is a passive header check, not an exploit. A permissive policy is not automatically a vulnerability; risk depends on the data and actions available from the endpoint.
What CORS actually protects — and what it does not
CORS is the single most misread security header on the web, so it is worth being blunt
about what it does. The same-origin policy stops JavaScript on a.com from
reading a response from b.com. CORS is how b.com opts out of
that restriction for chosen callers. It is a relaxation of a browser rule, not a
protection you add.
Three consequences follow, and each one surprises somebody:
- CORS does not protect your server. It is enforced by browsers, and only by browsers. curl, Postman, a Python script and any server-to-server caller ignore it completely. If an endpoint needs protecting, it needs authentication and authorisation — a restrictive CORS policy in front of an unauthenticated API protects nothing.
- The request is usually still sent. For a simple request the browser dispatches it, lets the server act on it, and only then refuses to hand the response body to the calling script. Any side effect has already happened.
- CORS is not CSRF protection. It blocks reading replies, not state-changing
requests. A form POST from an attacker's page is a simple request and is unaffected. You
still need anti-CSRF tokens or
SameSitecookies.
Simple requests and preflight
A request is simple — sent straight away, no preflight — when it uses GET,
HEAD or POST, carries only a short list of headers, and its Content-Type is
application/x-www-form-urlencoded, multipart/form-data or
text/plain. Anything else triggers a preflight: the browser first sends
OPTIONS with Access-Control-Request-Method and
Access-Control-Request-Headers, and only sends the real request if the reply
approves it.
This is why Content-Type: application/json matters. A JSON API is preflighted,
so the browser asks permission before the request lands. The same endpoint accepting
text/plain can be hit without any preflight at all — a common way a
supposedly protected API turns out to be reachable from any page.
The headers that decide the outcome
Access-Control-Allow-Origin— the one origin permitted to read the response, or*. It takes a single value; a comma-separated list is invalid and browsers reject it.Access-Control-Allow-Credentials— whether cookies andAuthorizationheaders may ride along. The spec forbids combiningtruewith*, which is why reflection appears (see below).Access-Control-Allow-Methods/-Headers— what the preflight approves for the real request.Access-Control-Expose-Headers— which response headers the calling script may read. Without it only a handful of safelisted headers are visible.Access-Control-Max-Age— how long a preflight result is cached. Long values make a policy change slow to take effect.Vary: Origin— easy to forget and genuinely dangerous to omit when the allowed origin is computed per request.
Five misconfigurations we find most often
1. Reflecting whatever Origin arrives, with credentials enabled. Because
* cannot be used with credentials, a quick fix is to echo the request's
Origin back and set Allow-Credentials: true. That grants
every site on the internet the right to make authenticated requests as your logged-in
user and read the replies. This is the single highest-impact CORS finding, and it is common.
2. Origin validation by substring. Allowlists built with “starts with”,
“ends with” or a loose regex are routinely bypassable. Matching the end of the
string lets evil-example.com through when you meant example.com;
matching the start lets example.com.attacker.net through. Compare the full
origin against an exact allowlist instead.
3. Trusting null. Sandboxed iframes, data: URLs and some
redirect chains send Origin: null. An attacker can produce that origin
deliberately, so Access-Control-Allow-Origin: null is an open door rather than a
safe default.
4. Missing Vary: Origin behind a shared cache. If the allowed origin is
chosen per request but the response is cached without varying on Origin, a CDN
can serve a response approving one origin to a visitor from another. The policy is correct
and the cache defeats it.
5. Trusting every subdomain. A wildcard over *.example.com means an XSS
or a forgotten staging host on any subdomain becomes a route into the API. Subdomains are
rarely all equally trustworthy.
Reading your result
Judge a policy by what sits behind the endpoint. Allow-Origin: * on a public,
unauthenticated, read-only endpoint — a font, a public price list, an open data feed
— is fine and intentional. The same header on an endpoint that returns user data, or
any policy that pairs a broad origin with credentials, deserves attention. Our probe sends an
ordinary cross-origin request from a throwaway origin; it does not authenticate, and it never
tries to exploit what it finds.
Fixing a permissive policy
- Keep an explicit allowlist of exact origins and compare the whole string.
- Echo back only an origin that is on the list, and send
Vary: Originwhenever you do. - Enable credentials only where a named origin genuinely needs them, never alongside a wildcard or a reflected value.
- Keep
Allow-MethodsandAllow-Headersto what the client uses. - Treat
nullas untrusted. - Remember that none of this authenticates anyone — keep the authorisation checks behind the endpoint.
Related checks: security headers analyzer and CSP evaluator. Running an API that browsers call cross-origin? We test authentication and authorisation across APIs as part of a scoped engagement.
Frequently asked questions
How do I fix “No ‘Access-Control-Allow-Origin’ header is present”?
The server you are calling must add Access-Control-Allow-Origin with your site’s origin to its response, and answer the OPTIONS preflight for non-simple requests. The fix is always on the API side; nothing in the calling page can override it.
Is Access-Control-Allow-Origin: * safe?
For public, read-only data that needs no login — fonts, open APIs, public JSON — yes. It is unsafe only when combined with responses that depend on cookies or other credentials, which browsers block anyway for *, so teams often switch to reflecting the origin instead. That reflection is the dangerous pattern.
Why is reflecting the request’s Origin header risky?
If the server copies any Origin back and also sends Access-Control-Allow-Credentials: true, every website a signed-in user visits can read that user’s data from your API. Check origins against an explicit allow-list instead.
Does this check log in or send any attack traffic?
No. It sends one cross-origin GET and one preflight from a test origin, without cookies or credentials, and reports the headers that come back.