Claude Sonnet 5.5 · Heavy

feat-2fa-backup-codes-cal-com

cal.com · TypeScript · M · 100–299 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 1
Comments published
6
Comments matching a bug
1
Comments not matching
5
Cost of this PR
$1.799

Published comments (6)

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

Backup code login bypasses password verification — One backup code is enough to log in because the password check is skipped whenever `credentials.totpCode` is non-empty, and the backup-code branch never validates `totpCode`. Verify the password whenever `credentials.backupCode` is present, e.g. `if (user.password && (!credentials.totpCode || credentials.backupCode))`.

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

Backup code consumption is non-atomic and allows reuse under concurrency — Because the read-modify-write on `backupCodes` isn't atomic, a single-use code can work twice, and parallel logins can overwrite each other's update and restore a consumed code. Make the update conditional on the previously read `backupCodes` value and fail the login if no row was updated.

mediumbugapps/web/playwright/login.2fa.e2e.ts:50-53

2FA enable assertion checks a Promise and can never fail — `isChecked()` returns a Promise, which is always truthy, so the assertion passes even when 2FA isn't shown as enabled. Close the dialog via `backup-codes-close`, then assert `two-factor-switch` with `data-state="checked"` is visible.

mediumbugapps/web/playwright/login.2fa.e2e.ts:110-122

Backup code download and copy checks do not verify file or clipboard content — The test passes even if the downloaded file or copied text is empty or wrong, since it only checks the static filename and a success toast. Read the downloaded file and the clipboard, and assert each holds 10 codes in XXXXX-XXXXX format.

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

Dismissing backup codes dialog skips onEnable and leaves stale state — Dismissing with Esc or an overlay click skips `onEnable()` and `resetState()`, so `viewer.me` isn't invalidated, the 2FA switch looks disabled, and reopening shows old codes from the stale `DisplayBackupCodes` step. Call `onEnable()` when the enable request succeeds, or run the same close logic from `onOpenChange`.

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

Backup code compared with non-constant-time indexOf — `indexOf` short-circuits, so response timing can leak information about the stored backup codes. Compare each stored code using `crypto.timingSafeEqual` on equal-length buffers, without early exit, to find the matching index. **Also found in:** - `apps/web/pages/api/auth/two-factor/totp/disable.ts:60-64`

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.