MiniMax M3 · 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
2
Comments matching a bug
0
Comments not matching
2
Cost of this PR
$0.239

Published comments (2)

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

TOCTOU race in backup-code consumption allows single-use code reuse — The read-modify-write of `backupCodes` is non-atomic, so two concurrent logins both pass `indexOf` before either `prisma.user.update` commits and the same code authenticates twice. Switch to an atomic update conditioned on the prior encrypted value, or store codes individually so DELETE-by-value is atomic.

mediumbugapps/web/components/settings/EnableTwoFactorModal.tsx:91-99

Unguarded body.backupCodes dereference crashes DisplayBackupCodes render — In `EnableTwoFactorModal.tsx`, `handleSetup` calls `body.backupCodes.map` without verifying the field exists, so a malformed response throws inside the catch and leaves the user at an empty `DisplayBackupCodes`. Guard with `Array.isArray(body.backupCodes)` before mapping, or route to the error branch.

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.