Repository navigation
fix: limit PIN guessing and lockouts in multi-attribute login (release/10.1) - #3731
Conversation
When the multi-attribute login resolves to more than one enabled, non-locked-out account and the credential does not identify exactly one, record the failure through the brute-force protector for each of those accounts. A new sharedCandidateFailurePolicy option (CHARGE_VIABLE_CANDIDATES by default, TUPLE_ONLY to count only the per-combination limit) selects this on both the browser form and the direct grant authenticator. With an encrypted credential attribute, a match on a locked account among several candidates now returns the same generic failure as any other failed attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the submitted values match several accounts but only one of them is not locked out, a failed encrypted-secret attempt is now attributed to that account, as the password path already does, whichever shared-candidate failure policy is configured. The response stays the same generic failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build every Keycloak image from quay.io/keycloak/keycloak:26.8.0 pinned by its manifest-list digest and compile all keycloak-extensions modules, idp-linking-authenticator included, against keycloak.version 26.8.0. Adapt the extensions to the 26.8 SPI: the admin CORS setup calls checkAllowedOrigins, and the URL truststore provider serves its realm CA material through the new HTTPS truststore accessors that X.509 client certificate validation reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin every Keycloak image to quay.io/keycloak/keycloak:26.7.5 by its manifest-list digest instead of 26.8.0. The oid4vp v0.6.2 extension calls SdJwtPresentationConsumer#verifySdJwtPresentation with the void signature that Keycloak 26.8 replaced, and no oid4vp release builds against 26.8 yet. Compile the keycloak-extensions modules against keycloak.version 26.7.0, the newest com.github.dasniko:keycloak-spi-bom release of the 26.7 line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
With Brute Force Detection on, a failed multi-attribute login that is attributed to one account no longer counts toward the per-tuple throttle: Keycloak already charges that account. The tuple key holds only submitted values, so anyone who knew a voter's values could fill it and keep the voter out even with the right password. Shared-tuple failures, and every failure in realms without Brute Force Detection, still count. The web login and IVR docs now advise strongly against date of birth + PIN login and describe a per-IP rate limit at the proxy, the only limit that tells an outsider apart from the voters they target. (cherry picked from commit 5caf67f) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performed
|
…tection The behaviour tables said that several password or PIN matches always fail; with FIRST_MATCH the first matching candidate logs in. The shared-candidate policy text now also says that CHARGE_VIABLE_CANDIDATES charges accounts only when the realm has Brute Force Detection on, as the resolver does. Web login and IVR docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…squash of fix/meta-13860/release/10.1) Squash of the PR's own changes at 136a140 (release/10.1...fix/meta-13860/release/10.1), without the release/10.1 commits merged into the topic branch. #3731 Related: sequentech/meta#13833 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keycloak's flow engine logs a failure after the authenticator returns, and this form has cleared the user by then, so the engine found nobody to charge. The form now charges the account itself, as it does for shared candidates. The Direct Grant flow keeps the user set, so Keycloak still charges it there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2f1f3417eb55de2cad8f451cfb11fc11ab097435)
C28 (meta-13862) moves the Keycloak extensions to 26.7, where BruteForceProtector.failedLogin takes a Set<String> instead of a String. chargeFailedLogin and two test verifications now pass a one-element set, as Keycloak's own AuthenticationProcessor does. 26.7.5's DefaultBruteForceProtector still allows "password", so the charge is unchanged. This PR is stacked on C28's and merges after it. Related: sequentech/meta#13860 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keycloak 26.7 clears a user's brute-force failures after a login only when the login recorded a counted credential type (password, OTP, recovery codes): AuthenticationManager.logSuccess passes the credentials the flow recorded through context.success(type), and DefaultBruteForceProtector .successfulLogin returns without clearing when there are none. 26.6.1 cleared them for an untyped success too. MultiAttributePasswordAuthenticator, its direct-grant variant and UsernamePasswordFormWithExpiry check the password and then called context.success(), so a correct login through them no longer reset the voter's failure count: found on a 26.7.5 env, where a voter who had mistyped a PIN stayed at one failure after logging in. They now call context.success(PasswordCredentialModel.TYPE), as Keycloak's own UsernamePasswordForm and ValidatePassword do. success(String) exists on 26.6.1 as well. MessageOTPAuthenticator is left as is: it checks a code sent by message against its own credential model, not Keycloak's OTP credential, and records no brute-force failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Failure accounting requires validation against real Keycloak 26.7 because mocked unit tests and success-only integration coverage do not verify failed-attempt charging, lockouts, or successful-login resets.
No open issues 🎉
What changed in this PR
Ports multi-attribute login hardening to release/10.1 for browser and IVR authentication. This depends on the stacked Keycloak upgrade.
Changes:
- Adds configurable failure accounting for shared candidates, defaulting to charging each eligible account.
- Excludes single-account failures from tuple throttling when Brute Force Detection is enabled, fixes browser failure accounting, and adds regression tests.
- Documents lockout behavior, DOB-and-PIN risks, and proxy rate-limiting recommendations.
| File | Description |
|---|---|
packages/keycloak-extensions/message-otp-authenticator/src/test/java/sequent/keycloak/authenticator/forgot_password/MultiAttributePasswordDirectGrantAuthenticatorTest.java |
Checks that Direct Grant exposes the new policy. |
packages/keycloak-extensions/message-otp-authenticator/src/test/java/sequent/keycloak/authenticator/forgot_password/MultiAttributePasswordAuthenticatorTest.java |
Tests shared-account charging, tuple throttling, and browser failure accounting. |
packages/keycloak-extensions/message-otp-authenticator/src/test/java/sequent/keycloak/authenticator/forgot_password/EncryptedAttributeLoginTest.java |
Tests encrypted-credential failure attribution and lockout behavior. |
packages/keycloak-extensions/message-otp-authenticator/src/main/java/sequent/keycloak/authenticator/forgot_password/Utils.java |
Adds policy configuration parsing and shared admin-console metadata. |
packages/keycloak-extensions/message-otp-authenticator/src/main/java/sequent/keycloak/authenticator/forgot_password/MultiAttributePasswordDirectGrantAuthenticator.java |
Exposes the shared-candidate failure policy. |
packages/keycloak-extensions/message-otp-authenticator/src/main/java/sequent/keycloak/authenticator/forgot_password/MultiAttributePasswordAuthenticator.java |
Charges attributed failures before clearing the user and exposes the policy. |
packages/keycloak-extensions/message-otp-authenticator/src/main/java/sequent/keycloak/authenticator/forgot_password/MultiAttributeCredentialResolver.java |
Implements shared-candidate charging and revises attributed-failure throttling. |
docs/docusaurus/docs/07-developers/12-ivr/dob-pin-direct-grant-authenticator.md |
Explains IVR failure policies, PIN risks, and rate-limiting guidance. |
docs/docusaurus/docs/02-election_managers/01-tutorials/101-admin_portal_tutorials_multi-attribute-password-login.md |
Documents browser failure policies, lockouts, and proxy safeguards. |
Review effort: Balanced
UsernamePasswordFormWithExpiry skips the password check when its disablePassword option is on, but still reported a password login through context.success(PasswordCredentialModel.TYPE). Conditional-credential steps and brute-force accounting read the credential type a login recorded, so that login looked like one that had checked a password. The form now records the password only when it checked one, and calls context.success() otherwise. The Direct Grant tests' failure and lockout paths check again that the no-argument success() isn't called either, besides success(any()). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a failureChallenge, Keycloak's flow engine charges the user on the authentication session or, with none, the account named by the ATTEMPTED_USERNAME note. The multi-attribute form clears the user and charges an attributed failure itself, but an earlier step in the same authentication session, such as another login form or a smart link, can have noted a username: the engine then charged that account as well, or instead of the one the failure belongs to. The form now removes the note when it fails. Lockouts use forceChallenge, which the engine doesn't charge, and the Direct Grant variant keeps the attributed user on the session for the engine to charge. Docs: a per-IP limit at the proxy is described as a mitigation, since the accounts sharing a value lock after the realm's failure factor, earlier failures and other addresses included. The IVR guide states that FIRST_MATCH works only with the PASSWORD credential policy: with SECRET_ATTRIBUTE every login fails with invalid_grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The documentation still misstates locked-account handling across credential modes and omits the unsupported SECRET_ATTRIBUTE/FIRST_MATCH combination, which would cause every login to fail.
2 open issues
Review effort: Balanced
Parent issue: sequentech/meta#13862 **C26's PR (#3731) is stacked on this one; merge this one first.** It carries the change C26's multi-attribute login needs on Keycloak 26.7 (`failedLogin` takes a `Set<String>`). Builds every Keycloak image (`Dockerfile.keycloak`, the three `Dockerfile.keycloak-vstl-*` files and the voter-enrollment integration Dockerfile) from `quay.io/keycloak/keycloak:26.7.5`, pinned by its manifest-list digest, and compiles every `keycloak-extensions` module, `idp-linking-authenticator` included (it was still on 26.4.0), against `keycloak.version` 26.7.0, the newest `com.github.dasniko:keycloak-spi-bom` release of that line. The image stays on 26.7 rather than 26.8 because the bundled oid4vp v0.6.2 extension calls `SdJwtPresentationConsumer#verifySdJwtPresentation` with the `void` signature that Keycloak 26.8 replaced, and no oid4vp release builds against 26.8 yet; a comment in `Dockerfile.keycloak` records this. Three things are adapted to 26.7: the admin CORS setup in `action-token-login-bridge` calls `checkAllowedOrigins`, as Keycloak's own admin endpoints do; `UrlTruststoreProvider` returns its realm CA material from the new `getHttps*` accessors, which X.509 client certificate validation now reads; and the password-checking authenticators (`MultiAttributePasswordAuthenticator`, its direct-grant variant and `UsernamePasswordFormWithExpiry`) call `context.success(PasswordCredentialModel.TYPE)`, since 26.7 clears a user's brute-force failures after a login only when the login recorded a counted credential; `UsernamePasswordFormWithExpiry` records none when its `disablePassword` option skips the password check. Keycloak migrates its database schema on first start, as with any Keycloak upgrade. Validation: every Keycloak FROM line is now 26.7.5 pinned by one digest and every keycloak.version is 26.7.0; a grep over Dockerfiles and poms for 26.6.1 or 26.4.0 finds the old values on the base branch and none here. The new UrlTruststoreProviderFactoryTest.realmProviderServesRealmCasForClientCertificateValidation passes; the module does not compile against the 26.7 SPI without the UrlTruststoreProvider change. Compiling all keycloak-extensions modules and spotless:check for the changed modules pass. Image builds, starting Keycloak against an existing database and the e2e login suites are left to CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Beltrán Rodríguez <beltran.rodriguez@sequentech.io>
…D mode SECRET_ATTRIBUTE rejects FIRST_MATCH, and verifies every enabled candidate, locked ones included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rvation With Keycloak's blocking default protector, a failure charged through failedLogin for an account this request never reserved enlists a removal that cuts the reservation suffix off whatever entry another request stored since. Charge such accounts through a plain DefaultBruteForceProtector on the session factory instead. Reserve the only unlocked candidate before testing its credential, so every failure attributed to one account is charged to an account this request reserved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(ovcs) (#4110) Parent issue: sequentech/meta#13860 Multi-attribute password login (browser form and IVR direct grant), on top of the shared-candidate charging already in `ovcs` (#3732): - **One account:** with Brute Force Detection on, a failure attributed to one account no longer counts toward the per-combination limit, which anyone who knows the voter's values could fill to keep them out even with the right password. The account is charged in Brute Force Detection instead: the browser form charges it itself, because Keycloak's flow engine logs a failure after the form has cleared its user (the form also drops any attempted username an earlier step noted, so the engine doesn't charge that account), and the direct grant keeps the user set so Keycloak does. Keycloak's lockout of that account applies. Without Brute Force Detection it still counts, and failures shared by several accounts always count. - **Docs:** the multi-attribute login tutorial and the IVR "DOB + PIN" page strongly advise against date of birth + PIN login and describe a per-IP rate limit at the proxy as a mitigation. Same change as on #3575 (release/10.0) and #3731 (release/10.1). Validation: `tupleThrottle_attributedFailuresWithBruteForceDetection_dontLockOutTheVoter` (MultiAttributePasswordAuthenticatorTest) and `attributedSecretGuessesUnderBruteForceDetectionDoNotLockOutTheVoter` (EncryptedAttributeLoginTest) fail on the base branch and pass with this PR; `tupleThrottle_sharedTupleFailuresWithBruteForceDetection_stillCount` and the existing tuple-throttle tests cover what still counts. `mvn -pl message-otp-authenticator -am spotless:check verify` passes locally (433 tests); the full keycloak-extensions suite and the docs build are left to CI. `action_attributedFailureChargesTheAccountBeforeClearingIt` fails without the charge in the browser form. That run was on the 10.0 branch (#3575); this port relies on its own CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Documentation** * Updated password-login and IVR guidance to warn about date-of-birth-and-PIN credentials and recommend unique voter identifiers, strong PINs, brute-force protection, and IP-based rate limiting. * Added guidance on applying proxy rate limits to browser and Direct Grant requests, including considerations for IVR traffic. * **Bug Fixes** * Corrected how attributable login failures affect tuple-based limits when Brute Force Detection is enabled; ambiguous failures continue to count toward those limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Parent issue: https://github.com/sequentech/meta/issues/13860
Stacked on C28's Keycloak 26.7.5 PR (#3739); merge that one first. Keycloak 26.7 changed
BruteForceProtector.failedLogin's credential type fromStringtoSet<String>, so this PR passes a one-element set and doesn't compile on 26.6.1. When C28's PR merges, GitHub retargets this one to the release.Multi-attribute password login (browser form and IVR direct grant):
sharedCandidateFailurePolicyoption selects this:CHARGE_VIABLE_CANDIDATES(default) orTUPLE_ONLY(only the per-combination limit counts the failure). Successful logins charge no other account, and voters who share a date of birth can still log in at the same time.DefaultBruteForceProtector, so it can't corrupt another request's reservation of that account. When several candidates share the values and only one is not locked out, that one is checked through the protector before its credential is tested. This relies on Keycloak's class layout: recheck it on Keycloak upgrades.Port of #3575, same commits. Validation: the shared-candidate tests don't compile against the base branch (they use the new policy setting);
tupleThrottle_attributedFailuresWithBruteForceDetection_dontLockOutTheVoterandattributedSecretGuessesUnderBruteForceDetectionDoNotLockOutTheVoterfail without the attributed-failure change.MultiAttributeCredentialResolverBlockingProtectorTest(real protector, overlapping reservation) andsharedTuple_soleViableCandidateBusyInAnotherRequest_isNotTestedOrChargedfail without the concurrency change. All pass with this PR.mvn -pl message-otp-authenticator -am spotless:check verifypasses locally (179 tests on 10.1); the full keycloak-extensions suite and the docs build are left to CI.action_attributedFailureChargesTheAccountBeforeClearingItfails without the charge in the browser form. That run was on the 10.0 branch (#3575); this port relies on its own CI.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation