# 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]]. ```php if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; // GET, HEAD bypass CSRF ``` **Format-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: ```html <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. [[raw/masimshahzad.medium.com/the-csrf-token-nobody-checked-14075|The CSRF Token Nobody Checked]] - **pac4j CVE-2026-40458** — `hashCode()` collision forges a matching token; fixed 5.7.10 / 6.4.1. [[raw/cert.pl/vulnerabilities-in-pac4j-software-7884|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. [[raw/daybreach.dev/phpmyadmin-csrf-token-bypass-via-non-ajax-post-to-sql-cve-2026-119426-12794|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. [[raw/github.com/thelia-back-office-csrf-token-leak-get-deletes-13244|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. [[raw/github.com/coder-csrf-protection-skipped-for-api-paths-matching-unanchored-exempt-13924|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_user` before CSRF check under `null_session`. [[raw/rubysec.com/alchemy-cms-csrf-protection-bypassed-in-admin-controllers-14678|alchemy_cms: CSRF protection bypassed in admin controllers]] - **Canva profile update** — `Rfcsrf` header required for JSON; form-encoded body accepted without it; email change → ATO path. [[raw/medium.com/critical-account-takeover-via-csrf-header-bypass-12488|Critical Account Takeover via CSRF Header Bypass]] - **"Eight Doors" ATO** — Angular sent `X-CSRF-Token` but a Spring prefix exclusion disabled enforcement on the recovery-email endpoint; plus `SameSite=None`, no Origin check, lenient `text/plain` parsing. [[raw/medium.com/eight-doors-one-key-chaining-misconfigurations-into-full-account-takeo-12490|Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover]] - **PetMemoria lab ($1,500, YesWeHack)** — backend accepted the literal placeholder `"csrf-token"`. [[raw/bblabs.es/wizard-takeover-ato-idor-csrf-lab-based-on-a-real-report-12598|Wizard Takeover ATO (IDOR + CSRF) lab based on a real report]] - **SourceHut CVE-2026-121728** — `/login` token reused to register when registration was closed. [[raw/blog.arusekk.pl/sourcehut-disabled-registration-bypass-via-login-csrf-token-cve-2026-1-14929|SourceHut disabled registration bypass via login CSRF token (CVE-2026-121728)]] - **Litestar** — unescaped CSRF token reflection → JS execution. [[raw/pretalx.com/bring-your-own-csrf-token-abusing-unescaped-tokens-chcon-2026-15522|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. [[raw/github.com/opentext-vibe-csrf-token-exposure-15219|OpenText Vibe CSRF token exposure]] - **Akeeba (CVE-2026-105296)** — improper token validation across Backup/Admin Tools. [[raw/jvn.jp/jvn-44272550-akeeba-products-csrf-cve-2026-105296-13425|JVN#44272550: Akeeba products CSRF (CVE-2026-105296)]] - **emlog pro** — `admin/ai.php` never calls `LoginAuth::checkToken()`; confirmation code hardcoded `confirm`. [[raw/github.com/emlog-pro-ai-assistant-csrf-to-sql-execution-poc-14911|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 - [[raw/masimshahzad.medium.com/the-csrf-token-nobody-checked-14075|The CSRF Token Nobody Checked]] - [[raw/cert.pl/vulnerabilities-in-pac4j-software-7884|Vulnerabilities in PAC4J software]] - [[raw/daybreach.dev/phpmyadmin-csrf-token-bypass-via-non-ajax-post-to-sql-cve-2026-119426-12794|phpMyAdmin CSRF token bypass via non-AJAX POST to /sql (CVE-2026-119426)]] - [[raw/github.com/thelia-back-office-csrf-token-leak-get-deletes-13244|Thelia back-office CSRF token leak + GET deletes]] - [[raw/github.com/coder-csrf-protection-skipped-for-api-paths-matching-unanchored-exempt-13924|coder: CSRF protection skipped for API paths matching unanchored exemption patterns]] - [[raw/rubysec.com/alchemy-cms-csrf-protection-bypassed-in-admin-controllers-14678|alchemy_cms: CSRF protection bypassed in admin controllers]] - [[raw/medium.com/critical-account-takeover-via-csrf-header-bypass-12488|Critical Account Takeover via CSRF Header Bypass]] - [[raw/medium.com/eight-doors-one-key-chaining-misconfigurations-into-full-account-takeo-12490|Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover]] - [[raw/bblabs.es/wizard-takeover-ato-idor-csrf-lab-based-on-a-real-report-12598|Wizard Takeover ATO (IDOR + CSRF) lab based on a real report]] - [[raw/blog.arusekk.pl/sourcehut-disabled-registration-bypass-via-login-csrf-token-cve-2026-1-14929|SourceHut disabled registration bypass via login CSRF token (CVE-2026-121728)]] - [[raw/pretalx.com/bring-your-own-csrf-token-abusing-unescaped-tokens-chcon-2026-15522|Bring Your Own CSRF Token: abusing unescaped tokens (CHCon 2026)]] - [[raw/github.com/opentext-vibe-csrf-token-exposure-15219|OpenText Vibe CSRF token exposure]] - [[raw/jvn.jp/jvn-44272550-akeeba-products-csrf-cve-2026-105296-13425|JVN#44272550: Akeeba products CSRF (CVE-2026-105296)]] - [[raw/github.com/emlog-pro-ai-assistant-csrf-to-sql-execution-poc-14911|emlog pro AI Assistant CSRF to SQL execution PoC]] - [[raw/intigriti.com/csrf-advanced-exploitation-guide-intigriti-4254|CSRF: Advanced Exploitation Guide - Intigriti]] - [[raw/cobalt.io/csrf-bypasses-cobalt-3427|CSRF & Bypasses - Cobalt]] - [[raw/book.hacktricks.xyz/csrf-cross-site-request-forgery-hacktricks-2874|CSRF (Cross Site Request Forgery) - HackTricks]] - [[raw/medium.com/csrf-the-bug-everyone-declared-dead-and-nobody-actually-fixed-13022|CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed]] - [[raw/medium.com/bypassing-csrf-token-validation-techniques-4830|Bypassing CSRF Token Validation Techniques]] - [[raw/appsecwriteups.com/escalating-self-xss-by-chaining-csrf-and-analyzing-captcha-15627|Escalating self-XSS by chaining CSRF and analyzing CAPTCHA]] - [[raw/cheatsheetseries.owasp.org/cross-site-request-forgery-prevention-cheat-sheet-owasp-2877|Cross-Site Request Forgery Prevention Cheat Sheet - OWASP]] - [[raw/medium.com/a-deep-dive-into-csrf-protection-in-rails-ruby-inside-medium-957|A Deep Dive into CSRF Protection in Rails – Ruby Inside – Medium]]