Skip to content
Deployment hardening

CORS wildcard: when it is and is not a problem

Access-Control-Allow-Origin: * can be appropriate for an intentionally public, non-credentialed response. It is not authentication, and credentialed browser requests need an explicitly permitted origin rather than a wildcard.

Check your app free, first fix free
By Brennan ZamboUpdated
In short

Evaluate CORS against the response's intended audience and credential model. A public asset is different from a private account API. Do not reflect arbitrary origins or remove authorization to fix a browser error. Test allowed and disallowed origins, inspect preflight behavior and keep server-side permission checks independent of browser-origin policy.

Ask what the response is meant to expose

CORS controls whether browser scripts from one origin may read certain cross-origin responses. It does not prevent every non-browser client from making a request. An API requiring private access still needs authentication and authorization, regardless of how restrictive its CORS headers appear.

For an intentionally public read-only resource with no private credentials, a wildcard can be reasonable. Treating every wildcard as a confirmed critical leak creates noise. For a private account response, examine cookies, bearer tokens, actual returned data and the permitted origins before assigning meaning.

Understand credentials and preflights

Browsers do not allow Access-Control-Allow-Origin: * as the response permission for a credentialed fetch using credentials include. This restriction is not solved by adding another wildcard. Return an exact trusted origin where appropriate and handle credentials deliberately.

Some requests trigger a preflight OPTIONS request. The server needs to describe the allowed method and headers for that route. A successful preflight does not authorize the eventual business operation; the real request must still check the user and permission.

bash
curl --include --request OPTIONS \
  https://your-app.example/api/private \
  -H "Origin: https://your-frontend.example" \
  -H "Access-Control-Request-Method: POST" \
  -H "Access-Control-Request-Headers: content-type"

This inspects a response outside a browser. It does not emulate every browser restriction or prove the endpoint's authorization. Use your actual frontend for the final controlled test.

Do not turn an origin header into trust

If the server reflects any supplied Origin value while allowing credentials, an attacker-controlled site may receive a response that was intended only for your frontend. Use an explicit allowlist based on the deployed application's real origins, not a string-contains check that accepts lookalike hosts.

An Origin header is also not a substitute for identity. A non-browser caller can send arbitrary headers. Validate sessions and ownership at the server boundary, and apply the relevant CSRF defenses for cookie-authenticated state changes.

Fix the actual route and cache behavior

Inspect the response that the browser blocks. A proxy, redirect or error handler may omit headers even when the normal success route includes them. If the returned policy varies by allowed origin, review Vary: Origin and the serving cache's behavior so one origin's response is not inadvertently reused for another.

Do not solve a CORS error by disabling authentication, exposing a private key or routing every request through an unrestricted public proxy. That can make a browser message disappear while creating a more serious security boundary failure.

Keep the scan conclusion bounded

A public check can observe policy headers and supported origin behavior. It cannot establish that a private authenticated response is vulnerable without the corresponding authorized test. Keep the distinction between a questionable configuration and confirmed unauthorized data access clear.

Turn the check into a release decision

Keep a small record of the production URL, the time you checked it, the exact finding and the action you took. A local preview and a deployed application can have different environment variables, response headers and database projects. After a repair, deploy the intended version and check the public address again. Do not assume that changing a repository file changed the live system.

Read coverage as carefully as the score. A timed-out asset, an ambiguous backend configuration or a request that could not safely establish access should remain unknown. It should not disappear from your release notes merely because there is no red finding. If a check was not completed, decide who will review it and what additional evidence is needed.

ProofForge's free report includes the first fix. The $9 Fix Report unlocks all findings' available repair guidance and builder prompts, with a PDF and private report link. Fix + Guard costs $29 once and adds builder rules, on-demand deploy-hook scans for 30 days and four weekly rechecks you start yourself. These are different deliverables, not different promises that an application is completely secure.

Keep private report URLs out of public issues and commits. If you need shareable evidence, use the owner-verification and publication flow for an eligible receipt. A signature protects the recorded assessment against undetected changes; it does not make the assessment exhaustive, prove a business outcome, or show that a later deployment still matches an earlier result.

Questions builders ask

Is Access-Control-Allow-Origin: * always unsafe?
No. It can be correct for intentionally public, non-credentialed resources. Evaluate the response's actual sensitivity and credential model.
Does CORS protect my API from curl?
No. CORS is enforced by browsers for cross-origin script access. Server authentication and authorization remain necessary.
Should I reflect the request Origin to stop errors?
Not without validating it against an intentional allowlist. Blind reflection can permit an attacker-controlled origin.

Continue with a related guide

Sources

Read-only, about a minute

Scan your app free

See what your live app ships to every visitor, with the first fix free. A clean scan is not a full audit. Run it only on an app you own or have permission to test.

Scan your app free
All guides