DeepSeek V4 Pro · Heavy
feat-2fa-backup-codes-cal-com
cal.com · TypeScript · M · 100–299 lines · 6 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.
- Gold bugs found
- 4 of 8
- Comments published
- 7
- Comments matching a bug
- 4
- Comments not matching
- 3
- Cost of this PR
- $1.410
Published comments (7)
Backup code login bypasses password verification when totpCode is supplied — A valid backup code plus any dummy `totpCode` bypasses the password check above. Verify `credentials.password` against `user.password` before trusting the backup code.
Non-atomic backup-code consumption allows double-use or resurrection — Two logins on the same code can both pass `indexOf` before either write commits, or one write can clobber another and resurrect a used code. Use an atomic update keyed on the prior `backupCodes` value.
2FA enable invalidation skipped when dialog dismissed via X/Escape after success — The X/Escape path calls `onOpenChange` directly, so `onEnable()` never runs and the parent query stays stale. Trigger `onEnable()` on close as well, or drive invalidation from `onOpenChange`.
Backup-code comparison is case-sensitive and rejects uppercase codes — Codes are generated as lowercase hex, so an uppercase entry is rejected as `IncorrectBackupCode` despite being correct. Normalize with `.toLowerCase()` before comparison and set `autoCapitalize="none"` on the input.
Backup code copy test only waits for toast, not clipboard contents — The toast appears even when the clipboard write rejects or writes empty text, so this test never catches a broken copy. Grant clipboard-read permission and assert the actual contents.
Loose 2FA switch assertion can pass when switch is not checked — `.isChecked()` returns a truthy-then-falsy value here, so the assertion can pass when the switch is not checked. Wait for `data-state="checked"` or close the backup-code dialog first.
Backup code verification should use constant-time comparison — Early-exit string comparison leaks timing information about the code and its position. Compare the submitted code against every stored code with a fixed-work loop that accumulates differences before deciding. **Also found in:** - `apps/web/pages/api/auth/two-factor/totp/disable.ts:61-63`