Origin Reflection and Validation Flaws

Server-side Origin checks that echo an attacker-controlled origin into Access-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

FlawServer logic (paraphrased)Probe origin
Blind reflectionACAO = req.Originhttps://evil.com
Prefix matchorigin.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 dotorigin.endsWith("target.com")https://eviltarget.com
All subdomains*.target.com regexany taken-over or XSSable subdomain
localhost prefixorigin.startsWith("http://localhost")http://localhost.evil.com
Special charactersregex assumes [a-z0-9.-]https://target.com_.evil.com (Chrome/Firefox accept _; Safari is far looser)
nullnull in allowlistsandboxed 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: startsWith check, access-token theft, email change, ATO (same source).
  • Mobile carrier: trusted localhost through a prefix check (same source).
  • Games retailer: arbitrary subdomain reflection exposing a Base64 session cookie (same source).
  • vAPI API7: Origin: evil.com echoed with ACAC, leaking authkey (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).

Sources