Amazon Ergo 1.0 · 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 Opus 5.5.
- Gold bugs found
- 3 of 8
- Comments published
- 3
- Comments matching a bug
- 3
- Comments not matching
- 0
- Cost of this PR
- $2.415
Published comments (3)
Backup-code login bypasses password verification — A direct credentials-callback request with an email, valid `backupCode`, and any non-empty `totpCode` can create a session without a password because `if (user.password && !credentials.totpCode)` is the only check. Verify the password in the backup-code branch or bind the second-factor step to server-side state from the password step.
Backup-code consumption is a non-atomic read-modify-write — Concurrent `authorize` requests can read the same `backupCodes` array and pass `indexOf` before either writes, letting one one-time code create multiple sessions; different codes can also lose an update and resurrect a consumed code. Consume codes atomically with a transaction, conditional update, or per-code used markers.
onEnable skipped when backup-code step is dismissed via overlay or Escape — The parent skips viewer query invalidation, the success toast, and state refresh, leaving the 2FA switch stale and the one-time backup-code display effectively lost. Call `onEnable()` whenever the backup-code step is dismissed, not only from the Close button. **Also found in:** - `apps/web/components/settings/EnableTwoFactorModal.tsx:261-272`