DeepSeek V4.1 Flash · Balanced
feat-2fa-backup-codes-cal-com
cal.com · TypeScript · M · 100–299 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 1 of 1
- Comments published
- 5
- Comments matching a bug
- 1
- Comments not matching
- 4
- Cost of this PR
- $0.149
Published comments (5)
Backup-code login bypasses password when TOTP code is supplied — A request with a valid backup code and any `totpCode` logs in without the password, so a copied backup code alone unlocks the account. Verify the password unconditionally in the backup-code path before accepting the code.
Backup code comparison is case-sensitive, rejecting uppercase codes — Codes are stored as lowercase hex but `indexOf` matches them case-sensitively, so a user typing uppercase codes gets `IncorrectBackupCode` and is locked out. Normalize both sides with `toLowerCase()` before comparing, and apply the same fix in `apps/web/pages/api/auth/two-factor/totp/disable.ts`.
Backup code redemption has a non-atomic read-modify-write — Two parallel requests with the same code both pass `indexOf` and both authenticate, and concurrent redemptions of different codes can overwrite each other, breaking the single-use guarantee. Consume the code with an atomic conditional update, such as `prisma.user.updateMany` guarded by the original `backupCodes`, and fail when the count is not one.
resetState not called when modal is dismissed via X, Escape or backdrop — Closing the dialog with X, Escape, or the backdrop leaves `step` at `SetupStep.DisplayBackupCodes`, so reopening shows the previous codes with no Cancel button to escape. Call `resetState` from the dialog's open/close handler, not only from the footer buttons.
2FA backup-code dismissal skips onEnable and leaves stale step — Once the enable request succeeds, dismissing the dialog never calls `onEnable`, so the security page still shows 2FA as disabled, and the stale backup-codes step reappears on reopen. Call `onEnable` and `resetState` on dialog dismissal after the request succeeds.
Gold bugs found (1)
Gold bugs missed (0)
None.