CSRF Token Bypasses
Ways anti-CSRF tokens fail in practice: the token is issued but not enforced, enforced only on some methods, content types or routes, not bound to the session, predictable, leakable, or attacker-plantable.
How it works
A token defends only if, for every state-changing request in every accepted format, the server (1) requires it, (2) compares it to a value bound to this session, and (3) the value cannot be read, guessed or set by the attacker. Real bugs break one leg; the frontend still sends the token, so scanners mark the endpoint “protected”.
Techniques / payloads
Validation gaps (send each variant; compare to the baseline):
| Variant | Catches |
|---|---|
| Drop the parameter/header entirely | ”validate only if present” |
Keep the name, empty value (csrf=) | existence-only checks |
| Random value, same length | format-only checks |
| Token from attacker’s own session | global token pool / not session-bound |
Placeholder string (csrf-token) | backend never receives the rendered value |
Integer 0 via JSON ("_token": 0) | Laravel loose-comparison bypass noted by Cobalt |
| Stale/expired token | missing expiry |
Method-conditioned enforcement. Checks gated on REQUEST_METHOD === 'POST' skip GET/HEAD; combined with $_REQUEST merging, a token-protected POST becomes a one-click GET. Also try _method / X-HTTP-Method-Override where the check runs on the wire method but the handler routes on the override — see Method Override CSRF.
if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; // GET, HEAD bypass CSRFFormat-conditioned enforcement. The JSON path requires X-CSRF-Token/Rfcsrf, but the same route also parses application/x-www-form-urlencoded and skips the check — a plain form then works. See JSON CSRF.
Route exemptions. Exemption lists for agents/webhooks written as globs but matched as unanchored regex (derp/* exempts any path containing derp); framework config that disables CSRF for a whole legacy prefix (Spring ignoringRequestMatchers).
Ordering bugs. User loaded/memoized in a before_action before the CSRF check: Rails’ null_session strategy nulls the session but the memoized @current_user survives, so the forged request still runs as the user.
Token tied to a non-session cookie / naive double submit. If the server only checks cookie == param, an attacker who can write a cookie on the target (CRLF/header injection, sibling subdomain, plaintext-HTTP injection on a non-__Host- cookie) plants both halves:
<img src="https://target/?x=%0d%0aSet-Cookie:%20csrf=AAAA" onerror="document.forms[0].submit()">
<form action="https://target/email/change" method="POST"><input name="csrf" value="AAAA">…</form>Fails if the token is derived from the session cookie (you’d overwrite the victim’s session).
Weak token construction. pac4j compared tokens via Java String.hashCode(): collisions are computable without knowing the victim’s token, collapsing the space to 32 bits (CVE-2026-40458).
Leakage. Tokens in URLs (?_token=) leak through history, logs and Referer; tokens readable by JS or sent over plaintext; any XSS reads the token from DOM/meta tag or replays the header the app attaches. A reflected, unescaped token is itself an injection sink (Litestar, CHCon 2026).
Token scope reuse. A token minted for /login accepted by /register/step2 (SourceHut CVE-2026-121728).
Non-token gates. CAPTCHA or “type confirm” steps: test whether the value is single-use and server-verified. emlog’s write gate was the literal string confirm; one Self-XSS chain succeeded by reusing an unused CAPTCHA value.
Notable cases
- Messenger.com (2015) — clients sent the token, the new backend never rejected requests lacking it; site-wide CSRF. The CSRF Token Nobody Checked
- pac4j CVE-2026-40458 —
hashCode()collision forges a matching token; fixed 5.7.10 / 6.4.1. Vulnerabilities in PAC4J software - phpMyAdmin ≤ 5.2.3 (CVE-2026-119426) — token checks skipped on non-AJAX POST to
/sql,/database/sql; arbitrary SQL as the victim. phpMyAdmin CSRF token bypass via non-AJAX POST to /sql (CVE-2026-119426) - Thelia back office — single per-session
md5(random_bytes(32))token appended as?_token=to every URL; 39/40 delete routes and all toggle routes accept GET. Thelia back-office CSRF token leak + GET deletes - Coder (GHSA-jvgx-787p-cfmg) — unanchored exemption regex skips token and same-origin checks; exploitable from same-site workspace apps. coder: CSRF protection skipped for API paths matching unanchored exemption patterns
- Alchemy CMS 8.4.0–8.4.2 (GHSA-cqh4-xxr9-qc73) — memoized
current_userbefore CSRF check undernull_session. alchemy_cms: CSRF protection bypassed in admin controllers - Canva profile update —
Rfcsrfheader required for JSON; form-encoded body accepted without it; email change → ATO path. Critical Account Takeover via CSRF Header Bypass - “Eight Doors” ATO — Angular sent
X-CSRF-Tokenbut a Spring prefix exclusion disabled enforcement on the recovery-email endpoint; plusSameSite=None, no Origin check, lenienttext/plainparsing. Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover - PetMemoria lab ($1,500, YesWeHack) — backend accepted the literal placeholder
"csrf-token". Wizard Takeover ATO (IDOR + CSRF) lab based on a real report - SourceHut CVE-2026-121728 —
/logintoken reused to register when registration was closed. SourceHut disabled registration bypass via login CSRF token (CVE-2026-121728) - Litestar — unescaped CSRF token reflection → JS execution. Bring Your Own CSRF Token: abusing unescaped tokens (CHCon 2026)
- OpenText Vibe ≤ 4.0.8.7 (CVE-2026-3860) — token exposed over insecure connection / to JS. OpenText Vibe CSRF token exposure
- Akeeba (CVE-2026-105296) — improper token validation across Backup/Admin Tools. JVN#44272550: Akeeba products CSRF (CVE-2026-105296)
- emlog pro —
admin/ai.phpnever callsLoginAuth::checkToken(); confirmation code hardcodedconfirm. emlog pro AI Assistant CSRF to SQL execution PoC
Defenses
- Enforce centrally (deny-by-default middleware), on the effective method, for every content type the route parses; reject missing, empty or malformed tokens.
- Bind to session: synchronizer token, or signed double-submit (HMAC over session-bound value + random, constant-time compare). Naive double-submit is discouraged.
- Never put tokens in URLs; rotate on login; scope per form/action where feasible (Rails per-form tokens, one-time-pad masking against BREACH).
- Anchor exemption patterns; test with two accounts (cross-session token reuse only shows up that way).
- See CSRF Prevention.
Related
- Cross-Site Request Forgery
- CSRF Prevention
- Method Override CSRF
- JSON CSRF
- SameSite Cookies
- Login CSRF
- Stored XSS
Sources
- The CSRF Token Nobody Checked · original
- Vulnerabilities in PAC4J software · original
- phpMyAdmin CSRF token bypass via non-AJAX POST to /sql (CVE-2026-119426) · original
- Thelia back-office CSRF token leak + GET deletes · original
- coder: CSRF protection skipped for API paths matching unanchored exemption patterns · original
- alchemy_cms: CSRF protection bypassed in admin controllers · original
- Critical Account Takeover via CSRF Header Bypass · original
- Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover · original
- Wizard Takeover ATO (IDOR + CSRF) lab based on a real report · original
- SourceHut disabled registration bypass via login CSRF token (CVE-2026-121728) · original
- Bring Your Own CSRF Token: abusing unescaped tokens (CHCon 2026) · original
- OpenText Vibe CSRF token exposure · original
- JVN#44272550: Akeeba products CSRF (CVE-2026-105296) · original
- emlog pro AI Assistant CSRF to SQL execution PoC · original
- CSRF: Advanced Exploitation Guide - Intigriti · original
- CSRF & Bypasses - Cobalt · original
- CSRF (Cross Site Request Forgery) - HackTricks · original
- CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed · original
- Bypassing CSRF Token Validation Techniques · original
- Escalating self-XSS by chaining CSRF and analyzing CAPTCHA · original
- Cross-Site Request Forgery Prevention Cheat Sheet - OWASP · original
- A Deep Dive into CSRF Protection in Rails – Ruby Inside – Medium · original