Sovra Recon·Glossary · CORS

Misconfigured CORS: Definition, Risks, and Proper Configuration

By Solan Barlet, co-founder of Sovra Recon
Updated October 29, 2026

In short

CORS (Cross-Origin Resource Sharing) is the mechanism that allows a server to authorize sites from a different origin to read its responses, thereby relaxing the same-origin policy enforced by browsers. If configured incorrectly, it becomes a vulnerability: if the server trusts any origin while accepting cookies, a malicious site can read a logged-in user’s data, such as their profile or API keys. The rule is simple: an explicit whitelist of trusted origins.

How CORS Works

By default, a script running on site-a.example cannot read responses from api.site-b.example: this is the same-origin policy. The server can lift this restriction by returning the `Access-Control-Allow-Origin` header with the authorized origin, and `Access-Control-Allow-Credentials: true` if it accepts requests accompanied by cookies.

Browsers do not allow the use of the * wildcard with identifiers. To work around this limitation, some servers simply copy the origin received in the response, which effectively amounts to trusting everyone.

Common configuration errors

  • Reflected origin: the server returns the value of the received Origin header—whatever it may be—in the Access-Control-Allow-Origin header, along with the authorized identifiers.
  • Approximate validation: a check based on prefixes or suffixes that accepts site.example.attacker.net or attacker.example.
  • "null" origin allowed: This value can be generated from a sandboxed iframe controlled by the attacker.
  • If trust is granted to all subdomains, an XSS attack or takeover of just one of them is enough to read the data.

Proper Configuration

  • Maintain an explicit whitelist of origins and compare the received origin exactly.
  • Only allow identifiers for origins that actually need them.
  • Never allow the “null” origin.
  • Add `Vary: Origin` when the response depends on the origin, to prevent a cache from serving the wrong version.

Frequently asked questions

Does CORS protect against CSRF?

No. CORS controls who can read a response, not who can send a request: a form submitted from another site will still be sent. Protection against CSRF relies on anti-CSRF tokens and SameSite cookies.

Sources

Find out where an attacker would get in.

Our AI agents actually attack your scope, fully automated, and hand you the proof of every vulnerability.