Kimi K3.1 Pro · 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.011

Published comments (5)

mediumsecuritypackages/features/auth/lib/next-auth-options.ts:131-145

Backup-code login with any TOTP value bypasses password verification — A valid `backupCode` plus any non-empty `totpCode` grants access without verifying the password or TOTP value. Verify the password independently of second-factor fields before either the backup-code or TOTP branch.

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

Backup code consumption is vulnerable to concurrent reuse and lost updates — Validating and consuming `backupCodes` separately lets concurrent sign-ins reuse one single-use code; updates for different codes can also overwrite each other and resurrect a consumed code. Make consumption atomic with a serializable transaction, row lock, or optimistic version check, and authorize only after it succeeds.

mediumbugapps/web/components/settings/EnableTwoFactorModal.tsx:135

Dismissing the post-enable dialog skips onEnable and cache invalidation — The switch stays off and the parent's `viewer.me` cache remains stale when an `onOpenChange` dismissal skips `onEnable` after 2FA is enabled. Call `onEnable` immediately on success, or route every post-success close through the `backup-codes-close` completion path.

mediumbugapps/web/components/settings/EnableTwoFactorModal.tsx:276-279

Unawaited clipboard writes cause unhandled rejections and false success — A rejected `navigator.clipboard.writeText` promise causes an unhandled rejection while the success toast claims the backup codes were copied. Await the write, show success only after it resolves, and display an error toast on failure.

mediumbugapps/web/components/auth/BackupCode.tsx:22-25

Backup code input constraints are never enforced — An empty submission leaves users on the 2FA screen without an error because the login form's `noValidate` and Zod schema bypass these HTML constraints. Enforce `required`, `minLength`, and `maxLength` in `methods.register("backupCode")` or the resolver.

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.