Skip to content

chore: harden totp re-use and account enumeration#1758

Open
paustint wants to merge 1 commit into
mainfrom
sec/totp-acct-enumeration-hardening
Open

chore: harden totp re-use and account enumeration#1758
paustint wants to merge 1 commit into
mainfrom
sec/totp-acct-enumeration-hardening

Conversation

@paustint

@paustint paustint commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens authentication flows against account enumeration and one-time-code replay by tightening TOTP acceptance, enforcing single-use OTP consumption, and making credential/password-reset responses more uniform in timing and messaging.

Changes:

  • Tighten TOTP verification skew tolerance and add a DB-backed single-use guard for 2FA OTP codes.
  • Mitigate login enumeration by equalizing the account-not-found vs wrong-password bcrypt cost and unifying invalid-credentials messaging.
  • Reduce password-reset enumeration via timing by not awaiting the email-provider round trip.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
libs/auth/server/src/lib/auth.service.ts Introduces a smaller TOTP grace period constant and uses it during TOTP verification.
libs/auth/server/src/lib/auth.db.service.ts Adds dummy bcrypt work on account-not-found and unifies InvalidCredentials messaging.
apps/api/src/app/controllers/auth.controller.ts Adds TOTP replay protection via DbCacheProvider and makes password-reset email sending fire-and-forget.
apps/api/src/app/controllers/tests/auth.controller.spec.ts Extends api-config mock to include DbCacheProvider for controller tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/api/src/app/controllers/auth.controller.ts Outdated
Comment thread apps/api/src/app/controllers/auth.controller.ts Outdated
Comment thread libs/auth/server/src/lib/auth.db.service.ts Outdated
Comment thread apps/api/src/app/controllers/auth.controller.ts Outdated
Comment thread apps/api/src/app/controllers/auth.controller.ts Outdated
Comment thread libs/auth/server/src/lib/auth.db.service.ts Outdated
Comment thread apps/api/src/app/controllers/auth.controller.ts
@paustint paustint force-pushed the sec/totp-acct-enumeration-hardening branch from 2447730 to 5f76e55 Compare June 2, 2026 13:21
@paustint paustint requested a review from Copilot June 11, 2026 03:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread libs/auth/server/src/lib/auth.db.service.ts Outdated
Comment thread apps/api/src/app/controllers/auth.controller.ts
Comment thread libs/auth/server/src/lib/auth.service.ts
Comment thread apps/api/src/app/controllers/__tests__/auth.controller.spec.ts
@paustint paustint force-pushed the sec/totp-acct-enumeration-hardening branch from 5f76e55 to 395add3 Compare June 11, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants