Claude Opus 5.5 · 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
0 of 1
Comments published
3
Comments matching a bug
0
Comments not matching
3
Cost of this PR
$0.729

Published comments (3)

highsecuritypackages/features/auth/lib/next-auth-options.ts:139-156

Backup code consumption is not atomic, so one code can be reused concurrently — Two concurrent logins can both read the old `backupCodes`, match the same code, and each create a session. Use a conditional update on `id` plus the previous `backupCodes` value that rejects when no row changes, or a transaction with row locking.

mediumbugapps/web/components/settings/EnableTwoFactorModal.tsx:258-289

Dismissing modal on backup-codes step skips onEnable and resetState — The user query is never invalidated, so the switch still shows 2FA disabled after the server enabled it, and reopening shows the stale backup-codes step. In `onOpenChange`, call `resetState` and `onEnable` when closing on `DisplayBackupCodes`, or block dismissal on that step.

mediumbugapps/web/pages/api/auth/two-factor/totp/disable.ts:48-61

Non-string backupCode crashes endpoint with 500 instead of IncorrectBackupCode — A JSON number or object in `req.body.backupCode` passes the truthiness check, so `.replaceAll` throws and the client gets an unhandled 500. Return `IncorrectBackupCode` unless `typeof req.body.backupCode === "string"` before normalizing it.

Gold bugs found (0)

None.

Gold bugs missed (1)

criticalThe credentials authorize() skips the password check when any totpCode is present, and the new backup-code branch never validates that totpCode, so a backup code plus a dummy totpCode logs in without the account password.