Skip to content

Invalidate authentication sessions on credential reset and restrict implicit email verification #49007

Closed
2 of 2 issues completed

Description

@abstractj

Description

Two related hardening gaps remain after the pre-account takeover fix in 26.7 (PRs #47538 and #48208):

  1. "Sign out from other devices" does not invalidate active authentication sessions. When a user resets their password and checks "Sign out from other devices", only user sessions are terminated. Active authentication sessions (e.g., someone in the middle of a required action like Terms & Conditions or passkey registration) are unaffected and can still complete the flow and gain access.

  2. setEmailVerified(true) is called from multiple places beyond the verify-email action. This allows email to be implicitly marked as verified through unrelated flows, most notably IDP account linking via IdpVerifyAccountLinkActionTokenHandler. An account registered by one party can have its email silently verified when the legitimate owner links via a social provider, giving both parties access.

Version affected

All current versions. The original passkey registration variant was fixed in 26.7, but these gaps remain.

Expected behavior

  1. "Sign out from other devices" should invalidate all sessions for the user, including in-progress authentication sessions — not just established user sessions.
  2. setEmailVerified(true) should only be set when the email is actually verified through the dedicated verify-email required action. Other flows should either not mark the email as verified or require explicit email verification as a prerequisite.

Actual behavior

  1. Authentication sessions survive credential reset. Someone parked on a required action screen can complete login after the legitimate user has changed the password and opted to sign out other devices.
  2. setEmailVerified(true) is called from at least 7 locations:
    • VerifyEmailActionTokenHandler — the intended path
    • IdpVerifyAccountLinkActionTokenHandler — IDP account linking
    • UpdateEmailActionTokenHandler — update email confirmation
    • ExecuteActionsActionTokenHandler — admin-initiated execute actions
    • ResetCredentialEmail — password reset flow
    • LDAPStorageProvider — LDAP user import
    • AbstractTokenExchangeProvider — token exchange

Steps to reproduce

Auth session invalidation gap:

  1. Enable self-registration and verify email
  2. User A registers and completes login up to a required action (e.g., Terms & Conditions)
  3. User A (legitimate owner) resets password from another session and checks "Sign out from other devices"
  4. User A's first session (parked on Terms & Conditions) can still complete the action and gain access

Implicit email verification via IDP linking:

  1. Enable self-registration, verify email, and a social IDP (e.g., Facebook)
  2. Party A registers john@email.com with a password — does not verify email
  3. Legitimate owner of john@email.com later clicks "Login with Facebook"
  4. After Facebook authentication, Keycloak shows "Account already exists. Link account?"
  5. User confirms and re-authenticates via email verification (default in first broker login flow)
  6. IdpVerifyAccountLinkActionTokenHandler sets emailVerified=true
  7. Both Party A (via password) and the legitimate owner (via Facebook) can now access the account

Anything else?

  • Implementing auth session lookup by user requires changes to AuthenticationSessionProvider — this capability does not exist today
  • Restricting setEmailVerified(true) has usability implications for IDP linking and password reset flows
  • LDAP import and token exchange cases are lower risk (admin-controlled or based on external IDP assertions) but should be reviewed for consistency

This issue was originally tracked in the private repository. Migrated by @abstractj.

Metadata

Metadata

Assignees

Fields

No fields configured for weakness.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions