Repository navigation
Conversation
mabartos
commented
Nov 12, 2026
Member
- Closes [CVE-2026-118030] HOTP Race Condition — Single OTP Code Reused for Multiple Concurrent Logins #54414
- HOTP and recovery codes: conditional updates prevent concurrent reuse.
- WebAuthn, including passwordless: counter updates retain the validated credential snapshot.
- Password rehashing: already uses conditional updates. TOTP: already uses atomic single-use tracking.
…ltiple Concurrent Logins Closes keycloak#54414 Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The security fix requires confirmation that concurrency tests pass across supported databases, especially MySQL/MariaDB, because locking and isolation semantics matter for both local and federated credential storage.
No open issues 🎉
What changed in this PR
Addresses #54414 by using conditional credential updates to prevent concurrent reuse of HOTP and recovery codes, and to preserve the validated WebAuthn credential snapshot during counter updates.
Changes:
- Makes HOTP and recovery-code validation succeed only when the conditional update succeeds.
- Uses the original credential snapshot for WebAuthn counter updates, including passwordless authentication.
- Adds local and federated storage tests for concurrent validation, HOTP rollback, and WebAuthn counter handling.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/model/CredentialConcurrencyTest.java |
Adds concurrency and credential-state regression tests. |
services/src/main/java/org/keycloak/credential/WebAuthnCredentialProvider.java |
Preserves the validated snapshot for conditional counter updates. |
services/src/main/java/org/keycloak/credential/RecoveryAuthnCodesCredentialProvider.java |
Consumes recovery codes through conditional updates. |
services/src/main/java/org/keycloak/credential/OTPCredentialProvider.java |
Advances HOTP counters through conditional updates. |
Review effort: Balanced
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.