How CORS Misconfiguration Works in Practice
The browser Same-Origin Policy blocks evil.com from reading responses from api.bank.com. However, if api.bank.com blindly echoes back Access-Control-Allow-Origin: https://evil.com (or trusts weakly validated subdomains/regexes) with credentials enabled, JavaScript on evil.com can fetch the logged-in victim private API data and exfiltrate it.
Defensive Mitigation & Hardening Checklist
Validate Origin headers against a strict exact-match allowlist of trusted origins, never combine wildcard/reflected origins with Access-Control-Allow-Credentials: true, and reject the "null" origin.