GHSA-7jg8-8m5x-6j9r: vaultwarden: device-level 2FA "remember" tokens survive admin-initiated 2FA removal, allowing 2FA bypass for up to 30 days (residual gap in fix f1ff613)
- Published:
- Fetched:
- Updated:
- Affects:
- dani-garcia vaultwarden
https://github.com/dani-garcia/vaultwarden/security/advisories/GHSA-7jg8-8m5x-6j9r ↗
vaultwarden: device-level 2FA "remember" tokens survive admin-initiated 2FA removal, allowing 2FA bypass for up to 30 days (residual gap in fix f1ff613) ## Summary Commit `f1ff613` ("revoke 2FA remember tokens when credentials or 2FA change", released in 1.37.3) established that whenever a user's second factors change, every device's 30-day `twofactor_remember` token must be revoked. The fix covered the user self-service paths, the recovery-code path, and the security-stamp rotation chain - but missed the two administrative remediation paths that strip a user's second factor: - the admin panel endpoint `POST /admin/users//remove-2fa` (`src/api/admin.rs:508-514`), and - organization account recovery with `resetTwoFactor=true` but `resetMasterPassword=false` (`src/api/core/organizations.rs:3072-3077`) - the standard "the attacker enabled their own 2FA on the victim's account, remove it" response flow. After either remediation runs and the victim re-enrolls a brand-new second factor, a device holding a stale remember token still skips 2FA entirely: we reproduce at runtime against the official `vaultwarden/server:latest` image (1.37.3) that the same device which captured a remember token before the remediation logs in with HTTP 200 and receives an `access_token` while the new TOTP is active - and that the identical token is rejected (400) once a *covered* path (password change) fires, isolating the residual exactly. All released versions, including 1.37.3, and current main are affected. ## Details Code locations (master `061694d0`; identical at tag 1.37.3 unless noted): - Background - the audited fix: `f1ff613` (2026-09-08, released 1.37.3) added `Device::clear_twofactor_remember_by_user` calls to: user self-disable of a 2FA provider (`src/api/core/two_factor/mod.rs:154`), recovery-code login that deletes all 2FA (`src/api/identity.rs:907-912`), and the security-stamp rotation chain (`src/db/models/device.rs:266-273`, `rotate_refresh_tokens_by_user`). - Residual gap A: `src/api/admin.rs:507-514` - `remove_2fa` calls `TwoFactor::delete_all_by_user(...)` and clears `user.totp_recover`, but never calls `Device::clear_twofactor_remember_by_user`: ```rust async fn remove_2fa(user_id: UserId, token: AdminToken, conn: DbConn) -> EmptyResult { let mut user = get_user_or_404(&user_id, &conn).await?; TwoFactor::delete_all_by_user(&user.uuid, &conn).await?; two_factor::enforce_2fa_policy(&user, &ACTING_ADMIN_USER.into(), 14, &token.ip.ip, &conn).await?; user.totp_recover = None; user.save(&conn).await } ``` - Residual gap B: `src/api/core/organizations.rs` `recover_account` (function starts at line 3009): with `resetMasterPassword=false, resetTwoFactor=true` - the "strip the attacker's 2FA only" option - `TwoFactor::delete_all_by_user` runs at line 3073, but the security-stamp rotation chain (which does clear remember tokens) lives inside the `reset_master_password` branch (around line 3060) and is not entered. - Full sweep: of the five `TwoFactor::delete_all_by_user` call sites in `src/`, exactly these two do not clear `twofa Affected packages: rust:vaultwarden Patched: vaultwarden 1.37.4