Repository navigation
fix(auth): two-factor final audit fixes - #10750
Merged
Merged
Conversation
…sign out swept members everywhere, audit sign-in lockouts
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final-state audit fixes for two-factor (after #10723, #10739, #10748):
createdAt, via Better Auth'screateSession(..., overrideAll)). A stolen old session could mint a desktop handoff, redeem it for a "fresh" session and pass the passwordless 2FA enrollment check (enroll the thief's authenticator). The same inheritance stops a handoff from restarting an org's maximum session lifetime, which is measured fromcreatedAtrevokeAllUserSessions(userId, { revokeOAuthGrants: true })ends every session, moves the org cookie-cache version (no 5-minute cached tail, no repeated re-sweeps) and revokes OAuth grants after the sessions in the same transaction. The admin reset uses the same callauth.two_factor_lockedaudit entry the docs promise (recorded once, on the failure that sets the lock)TWO_FACTOR_REQUIREDmeant three things; split intoTWO_FACTOR_REQUIRED(enrolled user, unknown sign-in path),TWO_FACTOR_SETUP_REQUIRED(member who must enroll) andTWO_FACTOR_REQUIRED_BY_ORGANIZATION(can't turn off); client messages reuse the server constantsType of Change
Testing
lib/auth/two-factor/guard.integration.ts22/22 against real Postgres + the Better Auth handler. New: a handed-over desktop session from an hour-old sign-in can't enable 2FA without a password (red without the fix: enrollment succeeds); the sweep ends both of a member's sessions; a lockout is audited exactly once (an extra attempt after the lock returns 429 and adds no second entry); the disable refusal carries the org code. Each red-checked against the pre-fix codeapp/api/desktop/auth/handoff/route.test.ts,app/desktop,lib/organizations/members,use-verification.test.tsx(37 tests), biome, api-validation strict, boundaries, client-boundary, source-conventions, comment-hygiene, test-patterns, file-names, utils, explicit-any, tool-registry-boundary, type-check (pre-push); fullcheck:auditsand suites in CIChecklist
test-auditauthoring gate)