Skip to content

Username enumeration via empty-password timing #51887

Closed

Description

@rmartinc

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

authentication

Describe the bug

Keycloak calls AuthenticatorUtils.dummyHash() for a non-existent user during login so that user does not exist costs the same PBKDF2 as wrong password - an intentional anti-enumeration measure. That measure is inverted on the empty-password code path: when the submitted password is empty, an EXISTING user is handled by an early return that performs NO password hashing, while a NON-EXISTENT user still runs the full dummyHash PBKDF2. As a result, an unauthenticated attacker who submits an empty password can tell whether a username exists purely from response latency: an existing username responds about one PBKDF2 faster than a non-existent one. Brute-force protection is disabled by default, so nothing masks the latency.

So probably we need to modify that code path to also do the dummyHash also for existing users but empty password. Options:

  • In validatePassword(), when the password is empty, still run dummyHash (or the equivalent) before the early return, so an existing user with an empty password incurs the same PBKDF2 as the other cases.
  • Route the empty-password case through the same code path that hashes (e.g. treat empty as an invalid credential that still triggers the standard hash/verify or dummyHash), so existing and non-existent users are timing-indistinguishable regardless of whether the password is empty.

Thanks to Mike Read for discovering the timing issue.

Version

26.7.2

Regression

  • The issue is a regression

Expected behavior

Run the dummyHash for existing users.

Actual behavior

Run dummyHash in all code paths.

How to Reproduce?

Just compare the times in the different code paths.

Anything else?

No response

Activity

  1. added theissue type on Aug 20, 2026
  2. added
    kind/bug
    on Aug 20, 2026
  3. added
    area/authentication
    on Aug 20, 2026
  4. removed theissue type on Aug 20, 2026
  5. removed
    kind/bug
    on Aug 20, 2026
  6. added and removed
    area/authentication
    on Aug 20, 2026
  7. 24 remaining items

  8. added a commit that references this issue on Oct 8, 2026
    2f669b1
  9. added 2 commits that reference this issue on Oct 22, 2026
    92f0597
    e5aec87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Fields

No fields configured for weakness.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions