CORS
Cheat sheet · https://pcornel.dk/topic.php?topic=4753
Answer
CORS (Cross-Origin Resource Sharing) uses response headers like Access-Control-Allow-Origin to let browsers allow specific other origins to read responses. Never reflect arbitrary origins with credentials allowed.
Remember
- Allow only specific trusted origins.
- Never reflect any origin when credentials are allowed.
- Preflight requests check methods and headers.
First checks
curl -sI -H 'Origin: https://evil.example' https://<api>— CORS response- Access-Control-Allow-Origin values — no wildcard with credentials
- Allowed methods/headers — minimal
Verify in this order
cross-origin request → preflight → allowed origin check
Where it usually breaks
First mismatch in asset/subject identity → trust/authentication → authorization/policy → enforcement/control → telemetry/detection → protected outcome/response; preserve identity/policy/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4753