CORS Without the Myths
CORS is a browser-enforced cross-origin response-reading policy, not server authentication and not protection from non-browser clients.
Frame the problem
Security starts with a concrete asset, attacker capability and trust crossing.
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.
| Prevent | Detect | Recover |
|---|---|---|
| Allowlist exact origins and methods · Authenticate and authorize independently of CORS · Use credentials only where required | Log rejected origins and configuration drift | Contain 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.
Follow the attack
Safe conceptual simulation: capability → missing control → crossed boundary → asset impact.
- 1Attacker starts with: A hostile web origin, or a direct API client that is not constrained by browser CORS.
- 2The API reflects arbitrary origins, combines broad origins with credentials, or relies on CORS instead of authenticating and authorizing the caller.
- 3The weak or missing boundary control is crossed: One browser origin → another origin’s response
- 4Impact: A hostile origin may read credentialed responses; direct clients remain unrestricted by CORS.
- 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.
- • Allowlist exact origins and methods
- • Authenticate and authorize independently of CORS
- • Use credentials only where required
- • Log rejected origins and configuration drift
- • Contain the affected identity or component.
- • Scope access from audit evidence.
- • Fix the boundary and add a regression test.
- • Misconfiguration and new access paths can bypass the intended control.
- • A privileged insider or compromised control plane may still reach the asset.