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-request state bound to the initiating browser; no PKCE; callback establishes a session for any valid code.
  • SAML ACS — response correlated via unsigned RelayState instead of the receiving browser’s pending AuthnRequest; signature and InResponseTo validate 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

VariantImpact
Logout CSRF aloneannoyance / DoS; step in chains (force re-login on a phishing form, LostPass-style)
Login CSRF alonevictim enters data, uploads files, saves cards, submits reports into attacker account
+ self-XSS in attacker accountstored 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-specificXE-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-Site enforcement 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 Path and cleared under another survives, making state replayable (@fastify/oauth2).
  • SAML: replay an IdP response with a tampered RelayState into 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 /authorize CSRF token was also unenforced. Login CSRF via a replayable OAuth code (static state, no PKCE)
  • Seamless Auth API < 0.19.2 — state was HMAC-signed, 10-minute, single-use, with PKCE on, but not bound to the initiating browser; the PKCE verifier was derived server-side from state, so holding state+code was 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: random binding returned 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_login signed-request sign-in and GitHub/Discord callbacks skip the X-Desk-CSRF check 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 /login path but cleared with Path=/ → 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 state not 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) — githubOauthCallback omits 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 state in a mature product’s linking flow → ATO. OAuth-based CSRF: exploiting a flawed state parameter
  • OpenMage Magento LTS — OAuth confirm/confirmSimple lack 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/callback did not bind OIDC state to 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/refresh binds 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-Site enforcement) on login, logout and registration.
  • OAuth: per-request unpredictable state stored 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. Signing state does not bind it; carry a browser-held secret (hash inside state) and verify it before marking state used. 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.

Sources