fix: 2FA bypassed when enabled but TOTP secret is missing (fail-open) (#1286)
* fix: fail closed when 2FA is enabled but the TOTP secret is missing * test: totp_verify fails closed when secret missing, passes when 2FA off
This commit is contained in:
@@ -376,7 +376,10 @@ class AuthManager:
|
||||
return True # 2FA not enabled, always pass
|
||||
secret = user.get("totp_secret")
|
||||
if not secret:
|
||||
return True
|
||||
# 2FA is enabled but no secret is stored (corrupt/partially-written
|
||||
# auth.json). Fail closed — returning True here bypassed the second
|
||||
# factor entirely.
|
||||
return False
|
||||
# Check backup codes first
|
||||
backup = user.get("totp_backup_codes", [])
|
||||
if code in backup:
|
||||
|
||||
Reference in New Issue
Block a user