GPT-6.1 Sol · 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.590

Published comments (6)

highsecuritypackages/features/auth/lib/next-auth-options.ts:131

Backup-code login bypasses password verification when a TOTP code is supplied — A valid `backupCode` plus any nonempty `totpCode` allows authentication without a password or verified TOTP. Ensure the backup-code branch verifies the password rather than letting an unverified `totpCode` suppress that check.

highbugpackages/features/auth/lib/next-auth-options.ts:147-155

Concurrent backup-code logins can reuse codes or restore consumed codes — Concurrent requests can authenticate with the same code or overwrite each other's `backupCodes` changes, restoring consumed codes. Make consumption atomic by conditioning the update on the original encrypted `user.backupCodes` value and rejecting or retrying conflicts, or serialize verification and consumption in a suitable transaction.

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

Dismissing backup codes leaves the parent's 2FA status stale — Dismissing `EnableTwoFactorModal` with Escape or an outside click leaves the settings switch and badge showing 2FA as disabled after successful enablement. Refresh the parent's user query immediately after success, or make every dismissal from `SetupStep.DisplayBackupCodes` run the Close button's completion and reset logic.

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

Backup-code copy test passes without verifying clipboard contents — Users could lose recovery access while this test still passes because `EnableTwoFactorModal` shows the success toast without checking `clipboard.writeText`. Read the clipboard after clicking `backup-codes-copy` and assert that it contains the displayed backup codes.

mediumbugapps/web/playwright/login.2fa.e2e.ts:113-117

Backup code download test passes for empty or incorrect file contents — An empty file or incorrect recovery codes still pass because `download.suggestedFilename()` checks only the filename. Read the downloaded file and compare its contents with the displayed backup codes.

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

Backup-code verification leaks secret-dependent timing — Plaintext comparisons in `backupCodes.indexOf` and its early exit expose secret-dependent timing during authentication. Compare fixed-length buffers or digests with `crypto.timingSafeEqual`, handle invalid lengths safely, and scan every entry before deciding whether authentication succeeds. **Also found in:** - `apps/web/pages/api/auth/two-factor/totp/disable.ts:60-63`

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.