GLM-5.3 · 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
$1.155

Published comments (5)

criticalsecuritypackages/features/auth/lib/next-auth-options.ts:131-156

Backup-code login skips password verification, allowing access with leaked backup code — Anyone holding a leaked backup code can sign in without knowing the password, since this branch never calls `verifyPassword` and the earlier `user.password` check is skipped when `totpCode` is set. Verify `credentials.password` here, as disable.ts does, or make the check unconditional.

mediumbugapps/web/components/settings/EnableTwoFactorModal.tsx:134-136

2FA success path never calls onEnable(); parent state stale after dismiss — Dismissing via ESC, X, or overlay at the backup-codes step never refreshes the parent — the Switch still shows 2FA disabled and reopening shows stale codes. Call `onEnable()` when enable succeeds, or invoke it from `onOpenChange` when `step` is `DisplayBackupCodes`.

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

Backup code burn uses check-then-act race allowing same code twice — Two concurrent sign-ins with the same code both pass `backupCodes.indexOf(...)` before either write lands, so the code authenticates twice. Burn it atomically with `updateMany` keyed on the unchanged `user.backupCodes`, requiring `count === 1`, or use a locking transaction.

mediumbugpackages/features/auth/lib/next-auth-options.ts:144-145

Backup code comparison is case-sensitive; uppercase input is wrongly rejected — Codes are generated as lowercase hex, but the `XXXXX-XXXXX` placeholder invites uppercase, so a correctly typed uppercase code is rejected with `IncorrectBackupCode` — locking users out of recovery. Apply `.toLowerCase()` before `backupCodes.indexOf(...)` (disable.ts needs the same), or unify generation and display.

mediumbugapps/web/components/auth/BackupCode.tsx:17-26

Backup-code input constraints never enforced, invalid codes silently dead-click — The `required` and length constraints are never enforced — the host form is `noValidate` and the zod schema uses `.passthrough()` — so an empty or short code submits with no feedback. Pass validation rules to `methods.register("backupCode", ...)`, or add the field to the zod login schema.

Gold bugs found (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.

Gold bugs missed (0)

None.