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)
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.
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`.
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.
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.
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)
Gold bugs missed (0)
None.