Origin Reflection and Validation Flaws
Server-side
Originchecks that echo an attacker-controlled origin intoAccess-Control-Allow-Origin, either with no validation at all or through string matching that an attacker-registered host satisfies. This is the root of most credentialed CORS Misconfiguration findings.
How it works
ACAO holds a single origin, so a server that trusts several origins has to read Origin, decide, and echo it back. Every flaw below is a mistake in that decision (Outpost24). The intended logic is an exact set-membership check (DarkRelay):
// correct: exact match on full origin
const ALLOWED = new Set(["https://app.target.com", "https://admin.target.com"]);
if (ALLOWED.has(req.headers.origin)) {
res.set("Access-Control-Allow-Origin", req.headers.origin);
res.set("Access-Control-Allow-Credentials", "true");
res.set("Vary", "Origin");
}Techniques / payloads
| Flaw | Server logic (paraphrased) | Probe origin |
|---|---|---|
| Blind reflection | ACAO = req.Origin | https://evil.com |
| Prefix match | origin.startsWith("https://target.com") | https://target.com.evil.com |
| Unanchored regex / substring | /target\.com/.test(origin) | https://target.com.evil.com, https://eviltarget.com |
| Suffix without dot | origin.endsWith("target.com") | https://eviltarget.com |
| All subdomains | *.target.com regex | any taken-over or XSSable subdomain |
localhost prefix | origin.startsWith("http://localhost") | http://localhost.evil.com |
| Special characters | regex assumes [a-z0-9.-] | https://target.com_.evil.com (Chrome/Firefox accept _; Safari is far looser) |
null | null in allowlist | sandboxed iframe, see Null Origin and Credentialed CORS |
Sources for the rows: blind reflection, startsWith, localhost, subdomain and underscore cases (Outpost24); reflection of evil.com, null and httpbin.org.evil.com all confirmed with one curl loop (Header Manipulation); the unanchored regex in Flickr’s fragment loader (Flickr XSS).
Context-dependent trust. Some endpoints return no CORS headers for their own origin but do trust a sibling. In Outpost24’s case, ta.app.io trusted travel-advice.com, and the same startsWith flaw applied to it. Burp’s built-in check only tries the scanned host, so it misses these. Fuzz the Origin over enumerated related domains first, then run the bypass set against each trusted one (Outpost24):
Origin: https://§sub.target.com§ # Intruder, URL-encoding off; grep ACAO
Third-party platforms on the allowlist. Developers allowlist GitHub Pages, CodePen or Replit for development and forget to remove them. Hosting the PoC there satisfies the check (Intigriti tips).
Subdomain trust is not safe. A takeover or XSS on any trusted subdomain gives a full read of the main origin. OWASP explicitly calls subdomain-regex CORS the “less secure” configuration because of Subdomain Takeover (Intigriti STO, OWASP CSRF CS). Same-site subdomain requests also carry SameSite=Lax/Strict cookies that have a Domain attribute (Outpost24). Mixed-content variant: trusted http:// subdomains abused by MITM (Top 10 2025 nominations).
Wordlists. PortSwigger’s URL validation bypass cheat sheet has a dedicated “CORS origin” context. Enter the allowed domain and an attacker domain and it generates domain-confusion, fake-relative and loopback payloads (Outpost24 contributed the localhost bypass) (PortSwigger intro, cheat sheet). The parser-confusion theory is in URL Parser Differentials.
Notable cases
- Bank: blind reflection on
/getSessionToken, giving session hijack (Outpost24). - Travel booking app:
startsWithcheck, access-token theft, email change, ATO (same source). - Mobile carrier: trusted
localhostthrough a prefix check (same source). - Games retailer: arbitrary subdomain reflection exposing a Base64 session cookie (same source).
- vAPI API7:
Origin: evil.comechoed with ACAC, leakingauthkey(vAPI). - $1,500 bounty: API domain with no origin allowlist plus ACAC; an XHR PoC read org and user data (Bugs in Plain Sight).
- Flickr (2013): unanchored regex let an attacker page serve HTML through CORS into
innerHTML, giving XSS (Flickr XSS). - Index of classic reflection writeups (pre-domain wildcard, BTC site, Google 404): Awesome Bug Bounty Writeups.
Defenses
- An exact-match set of full origins. No regex, no
startsWith/endsWith/contains, and no reflection fallback (OWASP HTTP Headers). - List specific subdomains rather than
*.domain. Accept the maintenance cost (Outpost24). - Strip dev, localhost and third-party-hosting origins from production configs.
- If you must parse, parse the origin as a URL and compare the scheme, host and port tuple. Don’t use string tests (the Flickr fix) (Flickr XSS).
Related
- CORS Misconfiguration (main guide) · Null Origin and Credentialed CORS · CORS on Internal and Local Services
- URL Parser Differentials · Referer and Origin Validation Bypasses · Subdomain Takeover · Cross-Site Scripting
Sources
- Exploiting trust: Weaponizing permissive CORS configurations · original
- HTTP Headers · original
- Cross-Site Request Forgery Prevention Cheat Sheet - OWASP · original
- HTTP Security Headers: A complete guide to HTTP headers · original
- Header Manipulation: Bypasses, Probing, and the Security Audit Nobody Does · original
- 31 Bite-Sized Tips and Bug Bounty Resources for 2026 · original
- Awesome Bug Bounty Writeups - Curated List by Bug Type · original
- One Missing Anchor, One Flickr XSS · original
- Exploiting All 10 OWASP API Security Risks in vAPI (+ Bonus Arena Challenges) · original
- URL validation bypass cheat sheet · original
- Introducing the URL validation bypass cheat sheet · original
- The Bugs Are Out There, Hiding in Plain Sight · original
- Hunting down subdomain takeover vulnerabilities · original
- Top 10 Web Hacking Techniques of 2025: Call for Nominations · original