Exploiting Origin Reflection Vulnerabilities
What you'll learn: How attackers exploit servers that blindly echo back the Origin header without validating it, bypassing CORS protections.
The Core Vulnerability
Some servers try to be "flexible" with CORS by dynamically setting the Access-Control-Allow-Origin header to match whatever Origin the client sends. This is called origin reflection. The server looks at your Origin header and simply mirrors it back in the response:
Your malicious request:
Origin: https://attacker.com
Server's unsafe response:
Access-Control-Allow-Origin: https://attacker.com
Access-Control-Allow-Credentials: true
This completely defeats CORS security! The server essentially says "whoever you are, you're allowed to read this response with credentials."
Why This Happens
Developers sometimes implement logic like "if the origin is in our whitelist, reflect it back." But if that check is broken, missing, or uses a flawed regex pattern, any origin gets reflected. The server becomes a yes-man, accepting all callers.
The Attack
An attacker hosts a malicious page at https://attacker.com with JavaScript that makes a credentialed request to the vulnerable server. Because the server reflects the attacker's origin and allows credentials, the browser permits the malicious script to read sensitive data—bypassing the Same-Origin Policy protections CORS was meant to enforce.
Real-World Analogy
Imagine a secure building where the guard asks "Who sent you?" If you say "Bob from accounting," they write you a pass that says "Authorized by Bob from accounting"—without actually checking if Bob exists or authorized you. You've just walked in unchallenged.
Key Takeaway:
Origin reflection vulnerabilities occur when servers blindly echo the Origin header without proper validation, allowing attackers to bypass CORS protections and access sensitive data from malicious domains.