Repository navigation
Description
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
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsDone
Activity
24 remaining items
Username enumeration via empty-password timing (#53733)
Username enumeration via empty-password timing
Username enumeration via empty-password timing