Webcorswithoutthemyths

CORS Without the Myths

CORS is a browser-enforced cross-origin response-reading policy, not server authentication and not protection from non-browser clients.

▶ Run the labFollow the failure

Frame the problem

Security starts with a concrete asset, attacker capability and trust crossing.

Asset
Which web origins may read API responses using a user browser.
Attacker & capability
A hostile web origin, or a direct API client that is not constrained by browser CORS.
Trust boundary
One browser origin → another origin’s response
AssetThreatAttack SurfaceTrust BoundaryVulnerabilityExploit PathImpactMitigationDefense in DepthResidual Risk

Why the system fails

The API reflects arbitrary origins, combines broad origins with credentials, or relies on CORS instead of authenticating and authorizing the caller.

The important question is not “what is CORS Without the Myths?” but “which assumption let untrusted data or an over-scoped identity cross one browser origin → another origin’s response?” Trace the decision at the boundary, then constrain what can happen after the first control fails.

Design the control in layers

Start with the control closest to the interpretation or privilege boundary: Allowlist exact origins and methods Then add a control that reduces blast radius and telemetry that proves the decision was enforced.

The resulting design is not labelled secure. Record the identified controls, the known failure paths, the remaining exposure, and the evidence you would need during an incident.

PreventDetectRecover
Allowlist exact origins and methods · Authenticate and authorize independently of CORS · Use credentials only where requiredLog rejected origins and configuration driftContain the affected identity or component, scope impact from audit evidence, and preserve a regression test.

Key points

  • Asset: Which web origins may read API responses using a user browser.
  • Boundary: One browser origin → another origin’s response
  • Primary control: Allowlist exact origins and methods
  • Detection signal: Log rejected origins and configuration drift
  • Always ask what limits damage when the primary control fails.

Boundary control exercise

This lesson uses the shared boundary-control exercise.

Boundary control check
Untrusted input / identity
Trust boundary
Privileged asset
Prevention may fail silently.

Follow the attack

Safe conceptual simulation: capability → missing control → crossed boundary → asset impact.

  1. 1
    Attacker starts with: A hostile web origin, or a direct API client that is not constrained by browser CORS.
  2. 2
    The API reflects arbitrary origins, combines broad origins with credentials, or relies on CORS instead of authenticating and authorizing the caller.
  3. 3
    The weak or missing boundary control is crossed: One browser origin → another origin’s response
  4. 4
    Impact: A hostile origin may read credentialed responses; direct clients remain unrestricted by CORS.
Blast radius
  • A hostile origin may read credentialed responses; direct clients remain unrestricted by CORS.

Defend, detect, recover

One prevention is a single point of security failure. Layer it and make failure observable.

Prevent
  • • Allowlist exact origins and methods
  • • Authenticate and authorize independently of CORS
  • • Use credentials only where required
Detect
  • • Log rejected origins and configuration drift
Respond & recover
  • • Contain the affected identity or component.
  • • Scope access from audit evidence.
  • • Fix the boundary and add a regression test.
Residual risk
  • • Misconfiguration and new access paths can bypass the intended control.
  • • A privileged insider or compromised control plane may still reach the asset.

Misconceptions

Claim
“A single allowlist exact origins and methods control makes this safe.”
Reality
One control changes risk; it does not erase it. Design prevention, detection, recovery, and blast-radius limits together.