Login CSRF
Forcing a victim’s browser to authenticate into an attacker-controlled account (session swapping), so the victim’s subsequent activity, data and linked identities land in the attacker’s account; most often caused by OAuth/SAML callbacks that are not bound to the browser that started the flow.
How it works
Inverse of classic CSRF: no victim session is ridden; instead a session is established. Sinks:
- Password login form without a pre-session token or Origin check.
- OAuth 2.0 callback —
code(or token) accepted without a per-requeststatebound to the initiating browser; no PKCE; callback establishes a session for any valid code. - SAML ACS — response correlated via unsigned
RelayStateinstead of the receiving browser’s pending AuthnRequest; signature andInResponseTovalidate the assertion, not browser ownership. - Signed-request / magic-link sign-in endpoints that accept an attacker-supplied credential blob without a CSRF header.
- Account-linking / connect flows (inverse case): the victim’s account gets linked to the attacker’s third-party identity → attacker logs in as the victim (that is ATO, not just login CSRF).
Impact ladder
| Variant | Impact |
|---|---|
| Logout CSRF alone | annoyance / DoS; step in chains (force re-login on a phishing form, LostPass-style) |
| Login CSRF alone | victim enters data, uploads files, saves cards, submits reports into attacker account |
| + self-XSS in attacker account | stored payload executes in victim’s browser on the real origin → credential phishing on a valid TLS origin, autofill theft |
| OAuth connect CSRF (victim linked to attacker IdP) | full Account Takeover |
| Product-specific | XE-0656: reading victim’s sealed reports and payout address (CVSS 8.6) |
Techniques / tests
- Login form: replay a login POST cross-site without token; check
Origin/Sec-Fetch-Siteenforcement before session exists. - OAuth: inspect
state— absent, static (state={"origin_uri": "/"}), not compared server-side, or not cleared after use. Mint a code in browser A, redeem the callback URL in fresh browser B; success = cross-session code acceptance. - Check PKCE presence (
code_challenge); check whether the callback refuses codes unrelated to the current browser context. - State-cookie hygiene: cookie set under one
Pathand cleared under another survives, makingstatereplayable (@fastify/oauth2). - SAML: replay an IdP response with a tampered
RelayStateinto an anonymous browser. - Logout: GET logout that re-sets the session cookie also reopens the Chromium Lax+POST window (SameSite Cookies).
Notable cases
- dkrypt writeup — static
state, no PKCE, no session binding; code minted in browser A logs browser B into A’s account; the/authorizeCSRF token was also unenforced. Login CSRF via a replayable OAuth code (static state, no PKCE) - Seamless Auth API < 0.19.2 —
statewas HMAC-signed, 10-minute, single-use, with PKCE on, but not bound to the initiating browser; the PKCE verifier was derived server-side fromstate, so holdingstate+codewas enough (RFC 9700 §4.7). The React SDK only blunted it by accident (pending-sign-in check); native and direct API clients had no check. Fix: randombindingreturned by/start, its SHA-256 inside the signed state, constant-time compare at callback before burning the state. We wrote an RFC 9700 matrix and it found a bug (OAuth state binding) - XE-17987 — reporter OAuth callback not bound to initiating browser; victim authenticates as attacker’s GitHub identity (identity grafting correctly blocked). Fix: nonce cookie bound to
state. XE-17987: OAuth callback not bound to initiating browser (login CSRF) - XE-0656 —
xe_loginsigned-request sign-in and GitHub/Discord callbacks skip theX-Desk-CSRFcheck enforced elsewhere; High. XE-0656: login CSRF signs a victim's browser into an attacker-chosen reporter identity - @fastify/oauth2 — state and PKCE verifier cookies set under
/loginpath but cleared withPath=/→ replayable state (from 7.2.0 / 7.6.0). Mitigations: patched release,cookie: { path: '/' },__Host-names. @fastify/oauth2 login CSRF via uncleared OAuth state cookie - social-auth-core SAML (GHSA-4pv2-52v7-vrfx, 4.7.0–6.2.0) — session selected from unsigned RelayState; fixed in 7.0.0 by correlating with the initiating browser’s AuthnRequest. social-core: login CSRF in SAML callbacks via RelayState
- social-auth-core < 7.0.0 (CVE-2026-126775) — crafted IdP responses + RelayState in the SAML backend. social-auth-core login CSRF
- NamelessMC — OAuth
statenot validated server-side; crafted callback swaps the victim into the attacker’s linked account. NamelessMC: OAuth callback state not validated, login CSRF - Keystatic ≤ 0.6.9 (GHSA-fv6w-2c5w-h387) —
githubOauthCallbackomits state validation; victim’s actions are committed under the attacker’s GitHub identity. Keystatic login CSRF - Vikunja < 2.8.0 — login CSRF. Vikunja login CSRF
- “Connect with Facebook” static state — predictable
statein a mature product’s linking flow → ATO. OAuth-based CSRF: exploiting a flawed state parameter - OpenMage Magento LTS — OAuth
confirm/confirmSimplelack form-key validation on GET; victim visiting confirm URL grants attacker consumer a persistent REST token. OpenMage Magento LTS cross-site request forgery (critical) - ZITADEL Login V2 4.0.0–4.20.2 (GHSA-fphg-99ff-7qrp) — the hosted Login V2 UI completed an external-IdP (OIDC/SAML) sign-in without checking that the finishing browser started it; a victim opening the attacker’s withheld link landed in the attacker’s ZITADEL account and everything they entered, uploaded or enrolled (integrations, auth methods) became attacker-retrievable. Window = IdP code lifetime or the 1h intent lifetime; MFA only interrupts it; Login V1 unaffected because it binds the browser; distinct from GHSA-jh3m-cr2x-qp88 (forgeable intent tokens). Fixed ≥ 4.20.3 by rejecting callbacks from any other browser. ZITADEL Login V2 login CSRF
- ByteStash 1.5.0–1.6.0 (CVE-2026-134799) —
/api/auth/oidc/callbackdid not bind OIDCstateto the initiating browser; attacker starts a login with their own account, withholds the callback URL and lures the victim into it, then reads the snippets the victim saves. Fixed 1.6.1. ByteStash login CSRF - ASP.NET Core CVE-2026-109481 — CSRF on
/_blazor/refreshbinds the victim’s authenticated principal to an attacker-owned circuit (EoP, CVSS 7.5). ASP.NET Core elevation of privilege via CSRF (CVE-2026-109481)
Defenses
- Pre-session CSRF tokens (or Origin/
Sec-Fetch-Siteenforcement) on login, logout and registration. - OAuth: per-request unpredictable
statestored server-side or in a__Host-cookie and cleared on use; PKCE for every client; refuse to establish a session from a code not tied to the current browser. Signingstatedoes not bind it; carry a browser-held secret (hash insidestate) and verify it before markingstateused. See OAuth 2.0 Vulnerabilities. - SAML: correlate responses with the receiving browser’s own pending AuthnRequest; never select session from
RelayState. See SAML Attacks. - Rotate session on login (Session Management); show the logged-in identity prominently.
Related
- Cross-Site Request Forgery
- OAuth 2.0 Vulnerabilities
- SAML Attacks
- Session Management
- Account Takeover
- SameSite Cookies
- CSRF Token Bypasses
Sources
- Login CSRF via a replayable OAuth code (static state, no PKCE) · original
- XE-17987: OAuth callback not bound to initiating browser (login CSRF) · original
- XE-0656: login CSRF signs a victim's browser into an attacker-chosen reporter identity · original
- @fastify/oauth2 login CSRF via uncleared OAuth state cookie · original
- social-core: login CSRF in SAML callbacks via RelayState · original
- social-auth-core login CSRF · original
- NamelessMC: OAuth callback state not validated, login CSRF · original
- Keystatic login CSRF · original
- Vikunja login CSRF · original
- OAuth-based CSRF: exploiting a flawed state parameter · original
- OpenMage Magento LTS cross-site request forgery (critical) · original
- ASP.NET Core elevation of privilege via CSRF (CVE-2026-109481) · original
- web application - Should login and logout action have CSRF protection? - In · original
- oauth 2.0 - How does CSRF work without state parameter in OAuth2.0? - Stack · original
- CSRF (Cross Site Request Forgery) - HackTricks · original
- CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed · original
- Lab: SameSite Lax Bypass via Cookie Refresh - PortSwigger · original
- CSRF - OWASP Foundation · original
- We wrote an RFC 9700 matrix and it found a bug (OAuth state binding) · original
- ZITADEL Login V2: external IdP callback not bound to browser (login CSRF) · original
- ByteStash login CSRF · original