GHSA-pfp2-jhgq-6hg5 / CVE-2026-47158: CSRF in SSO Authorization Flow
- Published:
- Fetched:
- Updated:
- Affects:
- dani-garcia vaultwarden
https://github.com/dani-garcia/vaultwarden/security/advisories/GHSA-pfp2-jhgq-6hg5 ↗
CSRF in SSO Authorization Flow ## Summary A cross-site request forgery / session fixation vulnerability in Vaultwarden's SSO authorization flow allowed an unauthenticated attacker to hijack any SSO user's login and obtain a fully authenticated session, leading to account takeover. The OAuth `state` parameter accepted by the authorize endpoint was not bound to the initiating browser session. Combined with a PKCE flow under attacker-controlled parameters and a cleanup gap on failed token exchange, an attacker could pre-create an authorization context, induce a victim to complete IdP authentication against it, and then redeem the resulting tokens themselves. ## Affected versions All Vaultwarden versions with SSO support up to and including 1.35.8. Versions 1.36.0 and up are not vulnerable. ## Root cause Three design decisions combined to produce the vulnerability: 1. **No session binding at `/connect/authorize`.** The endpoint accepted arbitrary client-supplied `state` and `code_challenge` values without authentication, cookies, or any other browser-session anchor. 2. **`SsoAuth` keyed by the client-supplied `state`.** The server-side record holding the OIDC flow context was primary-keyed on a value the caller controls, allowing an attacker to fixate a row and have a subsequent IdP callback bearing that `state` populate it. 3. **No cleanup of `SsoAuth` on failed token exchange.** When `exchange_code` propagated an IdP error (e.g. from a mismatched PKCE verifier), the row was left intact, preserving the victim's authorization code for later redemption. ## Attack chain 1. The attacker generates a PKCE `code_challenge`/`code_verifier` pair and a `state` value, then calls `/connect/authorize` with these. An `SsoAuth` row is stored keyed by the attacker's `state`, and the IdP authorization URL is returned. 2. The attacker sends the IdP URL to the victim. The victim authenticates with the IdP — if an IdP session is already active, no interaction beyond the click is required. 3. The IdP redirects the victim's browser to `/connect/oidc-signin` with their real authorization code. The server stores this code in the attacker-fixated `SsoAuth` row without verifying that the callback originated from the same browser that initiated the flow. 4. The victim's browser is redirected to `sso-connector.html`, where the Bitwarden client automatically attempts token exchange. Because the client does not hold the attacker's verifier, the exchange fails at the IdP. The `SsoAuth` row is not deleted. 5. The attacker calls `/connect/token` with the fixated `state` (which doubles as `code` in this implementation) and their own `code_verifier`. The exchange succeeds, the IdP returns the victim's identity, and access and refresh tokens for the victim's account are issued to the attacker. ## Impact - Full account takeover of any SSO user without two-factor authentication. - Access to the victim's encrypted vault material (`PrivateKey`, `Key`, ciphers), enabling offline b Affected packages: :vaultwarden Patched: vaultwarden 1.36.0