Claude Opus 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
- 0 of 1
- Comments published
- 4
- Comments matching a bug
- 0
- Comments not matching
- 4
- Cost of this PR
- $2.808
Published comments (4)
Backup code consumption races: one code can be reused or a used code restored — Parallel logins can reuse a single-use code, or one login's write can restore another's used code, since `indexOf` and `prisma.user.update` aren't atomic. Use a conditional `updateMany` matching the read `backupCodes` value and fail when 0 rows change, or use a serializable transaction.
Closing dialog on backup codes step skips onEnable and resetState — 2FA is already enabled on the server here, but Esc or an overlay click goes through `onOpenChange`, so the switch stays unchecked and the modal reopens stuck on `DisplayBackupCodes`. Wrap `onOpenChange` to call `resetState()` and `onEnable()` when closing during that step.
2FA enable test skips backup-codes close and asserts on a Promise — `onEnable()` never runs, yet the test passes because `isChecked()` returns a Promise, which is always truthy. Click `backup-codes-close`, then assert the `two-factor-switch` with `data-state="checked"` is visible (or use `toBeChecked()`), as the second test does.
Backup code check uses a non-constant-time comparison that leaks timing — `backupCodes.indexOf(...)` uses `===`, which stops at the first mismatched character, so response time can reveal how much of a guess was right. Compare against every stored code using `crypto.timingSafeEqual` on equal-length buffers without stopping early. **Also found in:** - `apps/web/pages/api/auth/two-factor/totp/disable.ts:60-64`
Gold bugs found (0)
None.