Referer and Origin Validation Bypasses
Failures of header-based CSRF defenses (Origin, Referer,
Sec-Fetch-Site): fail-open on a missing header, substring/regex matching, exempt entry points, trusting same-site, and browser behaviors that put the target’s own origin into an attacker-triggered request’s Referer.
How it works
Origin, Referer and Sec-Fetch-* are forbidden headers, so page JS cannot forge them — the defense is sound only if the comparison is an exact origin match and absence fails closed. Practical gaps:
- Absence. Browsers omit
RefererunderReferrer-Policy: no-referrer/<meta name="referrer" content="no-referrer">(or legacynever) /referrerpolicyattributes;Originis missing on many same-origin GETs and some form posts, andOrigin: nullappears underno-referrerin Chromium form POSTs. Missing ornullis not evidence of same-origin. - Loose matching.
includes/startsWith/unanchored regex accepthttps://target.com.evil.tld,https://evil.tld/?target.com,https://evil.tld/target.com. - Site vs origin.
Sec-Fetch-Site: same-siteis honest for sibling subdomains; policies that trustsame-site(or only rejectcross-site) inherit every sibling’s XSS, upload and takeover risk. - Header not evaluated. Middleware that skips the check for some content types (
text/ping), routes (exemption lists) or “index” pages. - Referer = target via sub-resources. Under default
strict-origin-when-cross-origin, a request initiated by a stylesheet or JS module hosted on the target carries the target’s origin as Referer, even when the attacker’s page linked that resource.
Techniques / payloads
Suppress Referer:
<meta name="referrer" content="no-referrer">
<form action="https://target/admin.php?action=installmodule" method="POST"
referrerpolicy="no-referrer" enctype="multipart/form-data">…</form>Launder the trusted string into the Referer (substring checks):
<meta name="referrer" content="unsafe-url"> <!-- default policy strips the query -->
<script>history.pushState('', '', '/?target.com'); document.forms[0].submit()</script>Sub-resource Referer (afine research): upload a file served as text/css whose url() points at a GET mutation on the target; link it from the attacker page with <link rel=stylesheet> — the resulting request’s Referer is the target. Only text/css works for stylesheets; cookies are not attached cross-site, so it becomes useful when linked from a same-site context. The JS-module variant has the same Referer behavior and accepts more content types but needs credentialed CORS for cookies.
Checklist:
- Remove
Referer; removeOrigin; sendOrigin: null. - Lookalike prefix/suffix domains and query/path embedding.
- HTTP vs HTTPS and port variants (exact origin includes scheme and port).
- From a sibling subdomain: does
Sec-Fetch-Site: same-sitepass? - Find entry points exempt from the check (index pages, OAuth/webhook routes) that redirect or chain into setters.
- Loopback/local services: missing Origin/Host checks enable DNS rebinding and browser-to-localhost CSRF.
Notable cases
- Pluck CMS 4.7.20 (CVE-2026-78748, CVSS 8.8) — Referer check logs a warning and returns
truewhen the header is absent; any admin action incl. module install (→ RCE). The bouncer who waves you in with no name tag: Pluck CMS missing-Referer CSRF (CVE-2026-78748) - Tasmota ≤ 16.0.0 (CVE-2026-119755) —
HttpCheckPriviledgedAccess()substring check passeshttp://.evil.com/<device-host>; arbitrary console commands. Tasmota through 16.0.0 CSRF (high) - Webmin 2.670 firewalld —
index.cgiis Referer-exempt and 302s intodefault_zone.cgi, which blocks foreign Referers when hit directly;referers_none=1default doesn’t close the hop. Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted - Warpgate 0.19.0–0.29.x (GHSA-qcwp-cwqv-g428) — no
Origin/Sec-Fetch-Sitecheck plusSameSite=None; bodilessPOSTendpoints approve tickets, grant admin roles, close sessions; fixed in 0.30.0 with origin +Sec-Fetch-Sitechecks. Warpgate cross-site admin actions without origin check - Hono
csrf()— Origin/Sec-Fetch-Sitenot evaluated fortext/ping. Hono csrf() misses hyperlink auditing text/ping POSTs - Coder — unanchored exemption regex skipped the same-origin check too. coder: CSRF protection skipped for API paths matching unanchored exemption patterns
- Playwright MCP Server < 0.0.40 (CVE-2025-9611) — no Origin validation on the localhost HTTP transport → DNS rebinding invokes MCP tools; fix adds
allowedHosts/allowedOrigins. CVE-2025-9611: Microsoft Playwright MCP Server CSRF Flaw - “Eight Doors” ATO — server never inspected
Origin/Referer, so it could not backstop broken token validation. Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover
Defenses
- Exact match of
Originagainst an allow-list of full origins; fall back to Referer origin only whenOriginis absent; reject when neither yields a trusted origin (and rejectnull). Sec-Fetch-Site: allowsame-origin(andnonefor user-typed navigations); treatsame-siteas untrusted unless every sibling is trusted; fall back to Origin checks whenSec-Fetch-*is missing. Go 1.25http.CrossOriginProtectionimplements this.- Apply checks independent of content type, route and method; anchor any exemption.
- Use as a layer with tokens, not instead — the afine sub-resource behavior shows Referer-only defenses are weaker than they appear.
- Localhost services: validate
HostandOrigin.
Related
- Cross-Site Request Forgery
- CSRF Prevention
- SameSite Cookies
- CSRF Token Bypasses
- DNS Rebinding
- MCP Security
Sources
- Bypassing Referer-Based CSRF with strict-origin-when-cross-origin · original
- The bouncer who waves you in with no name tag: Pluck CMS missing-Referer CSRF (CVE-2026-78748) · original
- Tasmota through 16.0.0 CSRF (high) · original
- Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted · original
- Warpgate cross-site admin actions without origin check · original
- Hono csrf() misses hyperlink auditing text/ping POSTs · original
- coder: CSRF protection skipped for API paths matching unanchored exemption patterns · original
- CVE-2025-9611: Microsoft Playwright MCP Server CSRF Flaw · original
- Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover · original
- CSRF: Advanced Exploitation Guide - Intigriti · original
- CSRF & Bypasses - Cobalt · original
- CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed · original
- CSRF (Cross Site Request Forgery) - HackTricks · original
- Using CORS policies to implement CSRF protection - Mixmax · original
- Cross-Site Request Forgery Prevention Cheat Sheet - OWASP · original
- Cross-site request forgery (CSRF) - Security - MDN Web Docs · original