Keycloak brute force detection and password policies

Keycloak brute force detection limits repeated failed sign-ins and password rules set the strength and lifecycle of user passwords. This page explains the options, the setup sequence, the trade-offs and what to confirm in your environment.

On this page

Keycloak brute force and password policy: what your team needs to decide first

Brute force detection in Keycloak slows or blocks repeated failed sign-in attempts against user accounts, and password policies set the rules a credential must meet when it is created or changed. If your organization has placed applications behind Keycloak and must limit password guessing and enforce credential rules, decide both before go-live, because users who sign in during the first weeks will shape your support load and your evidence trail. Both controls are configured per realm, so a single realm that serves employees, partners and customers will share one lockout and password posture unless you separate those populations into different realms.

The effect of these settings depends on what sits in front of them. Brute force protection applies to the login flows that check passwords, so a realm that relies mainly on federated sign-in through an external identity provider, passkeys or one-time codes will see different behavior from a realm using local passwords. Clients also matter. Confidential service clients, direct grant flows and API paths can bypass or interact with lockout differently than the browser login, so map every authentication flow and client that accepts a password before you decide thresholds. Ask whether your applications send users through the browser flow only, and confirm which flows your audit scope expects you to cover.

Decide the lockout model first. Keycloak offers temporary and permanent lockout modes, and the choice determines who can unlock an account, how long a locked user waits, and what your help desk must do at two in the morning. Permanent lockout usually means an administrator restores access, which needs a documented procedure, named approvers and a record of each unlock. Temporary lockout reduces that burden but requires you to set a wait period and failure threshold that fit your user population. Agree these values with your security owner and your service desk together, since each one trades attacker friction against legitimate user disruption.

Password rules are the second decision set. Keycloak's password policy can cover length and character requirements, password history, expiry, a blacklist of common or breached values, and the hashing algorithm used to store credentials, with Argon2 and PBKDF2 among the options. Your compliance owner should state which requirements your assessment tests, and your team should confirm which of these settings exist and what their defaults are in the Keycloak version you run, because defaults and option names have changed across releases. Record the chosen values in configuration as code so that later changes are reviewed and traceable.

Before you sign a written scope with DeployOpen, confirm four things with your team: the realms and clients in use, the authentication flows each one uses, the lockout model and thresholds you want, and the password rules your auditors expect. Confirm the exact settings and defaults against your running Keycloak version and your deployment method, then test lockout and password changes in a non-production realm that mirrors production flows. Those answers define the work, the verification evidence and the operating procedures that the scope should cover.

Which brute force and password settings fit which risk

This table compares Keycloak's brute force and password settings by the risk each one addresses, the operational side effect it creates for help desks, service accounts and users, and the situations where it fits. Read each row against your own threat model and user base, and confirm exact labels and defaults in the Keycloak server administration guide for your version. The main takeaway is that stronger lockout usually shifts effort to support, so plan the unlock process before you tighten the settings.

SettingRisk it addressesOperational side effectWhen it fits
Temporary lockoutRepeated password guessing against a user account, slowed by blocking further attempts for a periodLegitimate users get locked out and contact the help desk; attackers can trigger lockouts on other people's accountsRealms with many human users where the help desk can unlock accounts quickly
Permanent lockoutSustained guessing that would restart after a temporary block expiresAccounts stay disabled until an administrator re-enables them; help desk load rises and service accounts can stop authenticatingHigh-value administrator accounts with a defined, audited unlock process
Failure reset and wait incrementsRepeated failures that escalate the delay between attemptsUsers who mistype wait longer each time; the reset window decides how long earlier failures still countWhen you want friction to rise gradually instead of a hard block; confirm how the counter resets
Password length and character classesWeak passwords that are easy to guess or to crack after a hash leakMore forgotten passwords and reset requests; users may write passwords down if rules are hard to meetEvery realm; length is usually the strongest lever, so align the rule with your written standard
Password history and expiryReuse of old passwords, and compromised passwords staying valid indefinitelyForced changes create help desk tickets; frequent expiry can push users toward predictable patternsWhere a framework or internal policy requires history or periodic change; confirm current guidance first
Blacklists and username or email restrictionsPasswords that contain the username, email or common wordsBlacklists need an update process; users may not understand why a password was rejected without clear messagesWorkforce and consumer realms with high exposure to common or breached passwords
Hashing algorithm (Argon2 or PBKDF2)Offline cracking of stored password hashes after a database exposureStronger hashing raises CPU load on each login; changes apply to new or rehashed passwords, so confirm the migration behaviorWhen a stated hashing policy or hardware sizing requires a specific choice; otherwise test before changing defaults

How Keycloak counts failed logins and applies a lockout

Keycloak keeps a failure count for each user account and makes the lockout decision from that count, so the first thing to understand is what counts as a failure and what clears it. A failed password check for a known username adds to that user's record. Confirm in the server administration guide for your exact version whether a successful sign-in resets the count, whether attempts against unknown usernames are tracked, and whether counting also considers the client address. Since Keycloak 26.8, login failures are persisted to the database by default according to the upgrade notes, so counts survive restarts and are shared by every node in a cluster. That supports consistent enforcement, but it also means your database now records more security-relevant writes, and your capacity plan should reflect that.

Temporary and permanent lockout differ mainly in who ends the lock. A permanent lockout disables the account until an administrator re-enables it, so every triggered lock becomes a helpdesk ticket and possibly an identity recovery task. A temporary lockout blocks sign-in only for a set period and then allows attempts again, which keeps routine recovery automatic but gives an attacker a repeating opportunity after each wait. Neither mode is sufficient on its own. Decide which mode fits each population, such as workforce users with managed recovery or customer accounts with self-service reset. Then confirm the exact unlock path in the administration guide, including whether administrators can clear a lock early and whether the user is told that the account is locked.

The failure reset window and the wait increments interact in ways that surprise teams who set them independently. The reset window controls how long earlier failures count toward the threshold. If it expires before enough failures accumulate, the counter starts over, so a slow, spaced-out guessing pattern may never trigger a lock. Wait increments control how long a temporary lock lasts after repeated lockouts, typically growing with each cycle up to a maximum wait. Read the two together. A long reset window combined with aggressive increments can keep a user locked for a long time after a short burst of mistakes, while a short window with small increments barely slows a patient attacker. Build a table of the exact sequence your settings produce, and confirm its semantics against the version you run.

The central trade-off is between stopping guessing and creating denial-of-service risk against legitimate users. A low threshold with long waits makes online guessing expensive, but anyone who knows a username can deliberately fail sign-in and lock out a colleague or customer. That pattern lands on your support queue and disrupts work. A higher threshold protects legitimate users from that nuisance but leaves more room for guessing, so the right setting depends on what else stands in the way, such as strong password rules, multi-factor authentication, and alerting on spikes in failures. Decide the threshold per user population and per sign-in path, and record the reasoning, because auditors and incident responders will ask why the values were chosen.

Before anything reaches production, check the behavior in a separate test realm. Set the candidate values, script a controlled series of failed sign-ins against a test user, and confirm when the lock starts, how long it lasts, how it clears, and what the user sees at each step. Restart the server or a cluster node partway through the sequence to confirm that the persisted failure records keep the count. Then confirm that lock events appear in your event logging and metrics pipeline so the security team can see them. Finally, check that your runbook names who may unlock accounts and how that action is recorded. Take the actual values from the administration guide and your own test results, not from this page.

Setting up brute force detection and password policies in a Keycloak realm

This sequence turns lockout and password rules from a plan into tested realm settings, covering every sign-in path and federated user population, with logged evidence and a documented way back if a setting disrupts users.

  1. Confirm the Keycloak version and realm scope

    The platform engineering lead records the exact Keycloak version running in each environment and the distribution in use, whether community Keycloak or the Red Hat build of Keycloak, because menu names and defaults can differ between releases. They list every realm in scope and note which ones are shared across applications. Done means a written inventory exists with version, distribution, realm names and owners, and the team has confirmed the version against the upgrade notes for its line before changing any setting.

  2. Decide which realms and client populations are covered

    The identity owner and application owners agree which realms, clients and user populations receive brute force detection and password rules. They separate local Keycloak users from users federated from LDAP or Active Directory, service and machine accounts, and any accounts used by integrations. Each population gets a named owner and a note on whether Keycloak enforces its password rules or a directory does. Done means a signed-off coverage table lists every realm and population, and the team can point to the directory that owns each password.

  3. Configure brute force detection in a non-production realm

    An administrator enables brute force detection on a test realm that mirrors production client configuration, then chooses the lockout mode and thresholds the security owner approved. Temporary lockout and permanent lockout behave differently for recovery, so the team documents which mode applies to which population and who can unlock accounts. Done means the realm shows the saved settings in the admin console and the administrator can export the realm configuration for review.

  4. Set password policy rules, history, expiry and blacklist controls

    The administrator adds password policy rules for length, character classes, history, expiry and blocked values in line with the organization's written standard. Expiry and history rules are checked against the requirements the team has mapped from its own policy and any framework it must meet, and the blacklist is populated from an approved source. For directory-managed users, the team notes that these rules may not apply to passwords changed in the directory. Done means a test user cannot set a rejected password, and the exported policy string matches the approved standard line by line.

  5. Test sign-in paths for each client and federation source

    The test team signs in with a representative account from each population, through each client's login flow, using valid passwords, repeated failures and a password change where applicable. For LDAP or Active Directory users, they confirm whether a failed attempt counts toward Keycloak lockout and whether a password change must happen in the directory, since those passwords may be managed outside Keycloak. Done means a test matrix records the expected and observed result for every client and federation source, with any gap assigned to an owner.

  6. Verify failure logging and lockout events

    The security engineer triggers failed sign-ins and a lockout in the test realm, then checks that the failures and lockout are recorded in the Keycloak event store and reach the logging or SIEM pipeline the organization uses. They confirm the event types, timestamps and user identifiers appear as expected and that the metrics endpoint, if enabled, reflects the same activity. Done means a captured sample of each event type is attached to the change record and the security owner confirms the events are queryable.

  7. Promote the settings with a documented rollback

    The change owner applies the tested settings to production in an approved window, using the exported realm configuration so the values match the test realm. Before the change, the team writes a rollback record that names the previous settings, the export file, who can reverse the change and how each lockout can be cleared. After promotion, they repeat a short set of sign-in checks and confirm the audit trail. Done means production shows the approved settings, the rollback record is stored with the change ticket, and the rollback has been tested in the non-production realm.

Which password rules Keycloak enforces and where they do not apply

Keycloak's password policy is a set of rules configured per realm, and it governs the passwords that Keycloak stores and sets itself. The rules fall into four general families. The first shapes new passwords, for example through minimum length, character requirements, exclusion of the username, or custom pattern checks. The second is history, which blocks reuse of recent passwords. The third covers expiry and forced change, which set how long a password stays valid and when a user must replace it. The fourth is blacklist control, which rejects passwords known to be weak or compromised. Before you configure anything, decide which families your written password standard requires, because each one needs its own setting and its own evidence.

The policy does not reach every account that signs in to your applications. Users federated from LDAP or Active Directory often keep their passwords in the source directory, so Keycloak may not validate or store those credentials in the way the realm policy assumes. Whether a change made through Keycloak is written back to the directory, and whether the realm rules apply at all, depends on the federation mode and the sync settings. Users who sign in through an external identity provider, whether an OIDC or SAML broker or a social provider, authenticate at that provider, and the Keycloak password policy governs none of those credentials.

This creates a planning task that is easy to miss. Build an inventory of every user source in each realm, and mark which accounts have passwords that Keycloak actually controls. For the rest, the controls must sit in the source system: the directory's password policy, the external provider's rules, or multi-factor authentication enforced at the point of sign-in. Auditors who test password requirements will ask which system enforces each control, so the answer should be written down per user source, not assumed from the realm settings.

Confirm the details in the Keycloak server administration guide for your release. Check the exact rule names, the order in which Keycloak evaluates them, and whether a policy applies the same way on a user's password change as on an administrator's reset. Those behaviors can differ, and they determine what a user sees at each step. Then test each rule in a non-production realm with accounts from every user source you run, and keep the results as evidence of the configuration. Re-run the tests after each upgrade, because the defaults and the handling of federated accounts can change between releases.

Security and operational risks to plan for with lockout and password rules

Lockout and password rules protect sign-in, but they also create new ways for legitimate users and services to be blocked. The cards below pair each risk with its operational consequence and the control that keeps it manageable in your Keycloak deployment.

Lockout used to block legitimate users

Anyone who can submit failed sign-ins for a known username can trigger a lockout, so an attacker can disable a colleague's access without knowing their password. The consequence is help desk load and interrupted work for the length of the lockout. Choose temporary lockout where the business can absorb short delays, agree the failure thresholds and lockout duration with service owners, and confirm how the help desk unlocks accounts and records each action.

Lockouts on service and break-glass accounts

Service accounts used by integrations and break-glass administrator accounts can be locked by the same rules as ordinary users. That can stop a batch job, a directory sync or the only emergency sign-in path. Decide which accounts are excluded or handled under separate controls, document who may unlock them, and test the emergency sign-in path before you depend on it during an incident. Confirm the exemption options available in the Keycloak version you run before writing them into runbooks.

Lockout behavior behind a reverse proxy

Brute force detection keys on the client address Keycloak sees. Behind a reverse proxy or load balancer, that address may be the proxy itself or a masked value, so many attackers can appear as one client, or one attacker can appear as many. The result is either a lockout that affects everyone or no lockout at all. Confirm how forwarded address headers reach Keycloak, trust only the addresses your proxy controls, and test with failed sign-ins from two separate networks.

Predictable patterns from password rules

Rules that require specific character classes, mandatory regular expressions or frequent expiry can push users toward predictable substitutions, seasonal words and small numeric increments. Attackers try these patterns early in password spraying. The controls are a minimum length, password history, blacklist checks against known weak passwords, and expiry only where your standards require it. Review the policy with security and the help desk together, and confirm which checks your Keycloak version provides.

TLS and admin console exposure

Passwords and session tokens stay protected only if credential traffic is encrypted from the browser to Keycloak and across every internal hop. The admin console and Administration REST API should sit on a different hostname or context path from public sign-in URLs, with the reverse proxy restricting paths. Confirm TLS on every hop, limit administrative access to managed networks, and check that public routes cannot reach administrative paths.

Monitoring with metrics and login records

Lockouts and password failures are only useful if someone sees them. Keycloak exposes Prometheus-format metrics at /metrics on its management interface when metrics are enabled with the metrics option, and the 26.8 upgrade notes state that login failures are persisted to the database by default. Plan alerts for sustained failure spikes, confirm the management interface is not publicly reachable, and set event retention and SIEM forwarding so investigations have records to work from.

How Keycloak hashes passwords and what to check before changing the defaults

Keycloak stores a hash of each password, computed with a configurable algorithm, rather than keeping passwords in any recoverable form. The hashing settings belong to each realm, so a workforce realm and a customer realm can use different configurations. The supported options include Argon2 and PBKDF2, and the parameters that tune each algorithm, such as iteration counts or memory cost, can change between releases. Before you change anything, record the algorithm and parameters active in every realm, then confirm the defaults for the release you run in the Keycloak server administration guide and its release notes. Treat those documented values as a starting point for your own testing, since the exact default algorithm and parameters must be confirmed for your release.

The main trade-off is CPU cost. A stronger hashing configuration takes longer to compute on every password check, so sign-in latency rises for each user, and the effect is largest when many people sign in at the same time, such as after a maintenance window or at the start of a working day. Bulk operations feel the change too. Importing users with password credentials, or any job that creates or verifies many passwords, takes longer as the parameters increase. Measure sign-in latency on the hardware and node count you plan to run, at the peak login rate you expect, and include the import job in the same test. A setting that looks acceptable for a single test login can still build a queue on a busy cluster.

Existing password hashes are typically upgraded when the user next signs in successfully. Keycloak checks the submitted password against the stored hash and, when the realm's current settings differ, stores a new hash under those settings. A realm can therefore hold hashes from several algorithms or parameter sets at once, and accounts that never sign in again keep their old hashes. Ask the team to confirm how the release in use handles this upgrade path, whether any administrative action can trigger rehashing for dormant accounts, and whether your compliance evidence requires a count of accounts still on older settings. Record that residual population in your risk register, and confirm that password reset produces hashes under the new settings.

FIPS-oriented environments may restrict which algorithms you can select, so a choice that works in a standard build may be unavailable or unsupported in a FIPS configuration. Confirm the permitted algorithm list with the documentation for your release and with your cryptographic validation owner before you schedule a change, because the approved set depends on the cryptographic module in use. A practical sequence starts with a documented baseline, then a staging realm loaded with production-like user data, then a latency test at expected peak load that includes the import path, and finally a rollback plan that restores the previous realm settings. Test brute force detection and password policy settings in the same pass, because failed login handling also adds load and affects the results.

Limits to confirm before you commit to a lockout and password design

Brute force settings and password rules in Keycloak sit inside a larger control set. Each card names a boundary to test in your own environment before you sign off a design, along with the source to confirm it against.

Lockout applies per realm

Brute force detection is configured for each realm, so every realm you run needs its own lockout mode, failure thresholds and wait periods. A realm you forget to configure keeps its own settings, which can leave a login path unprotected. Confirm how temporary and permanent lockout behave in the server administration guide for your installed version, then list every realm and check its settings one by one.

Reverse proxy and WAF rules are separate

Keycloak's production guide calls for a reverse proxy with path restrictions, and for the admin console and Administration REST API to sit on a different hostname or context path from public frontend URLs. Rate limiting, request inspection and IP filtering at the proxy or web application firewall are controls you configure and own. Confirm which requests reach Keycloak directly in your topology, and whether your proxy also throttles token and login endpoints, not only the login form.

Password rules skip external identity providers

Password policy settings apply to passwords that Keycloak stores for its local users. Accounts federated from LDAP or Active Directory, and accounts that sign in through brokered OIDC, SAML or social providers, keep their credentials in the external system. For each federation or brokering link, confirm where the password is checked, which system enforces length, history and expiry rules, and whether Keycloak's lockout counters see failed attempts at all.

Hashing changes need performance sizing

Keycloak's Argon2 and PBKDF2 hashing defaults trade login cost for resistance to offline cracking. Changing the algorithm or its work factors changes the CPU time for each password check, which affects login latency and how many sign-ins each node can handle at peak. Size the change in a staging environment that matches your node count and CPU allocation, measure login throughput before and after, and confirm in the release notes how existing stored hashes are handled.

Confirm defaults against your installed version

The current Keycloak release is 26.8.1, published October 13, 2026. The 26.8 upgrade notes include changes that affect sign-in, such as login failures persisted to the database by default. Later release notes may change defaults again, and the project states that breaking changes in minor releases will be opt-in. Record the version you run, read the notes for every release between your current and target version, and retest lockout and password settings after each upgrade.

Control mapping belongs to the assessor

Keycloak does not map its lockout and password settings to specific requirements of a framework, and DeployOpen does not issue audit reports, attestations or certifications. An independent assessor decides whether a threshold, password rule or hashing setting meets a control requirement in your scope. Ask the assessor which evidence they accept, such as configuration exports and test records, and agree on that evidence before you finalize the design.

Questions teams ask before configuring Keycloak lockout and password rules

What drives the cost of configuring Keycloak lockout and password rules?

The scope you agree in writing drives the cost more than the settings themselves. Keycloak lockout and password policies are configured per realm, so the number of realms, the clients that depend on each realm, and the number of user federation sources (such as LDAP or Active Directory) all change the work. Existing password rules in other systems that must stay consistent, the depth of testing across login flows, and the change control your organization requires also add effort. DeployOpen does not publish a price list. A quote follows from a written scope that lists these items, and it should separate one-time configuration and testing from any recurring support you choose to add.

How long does Keycloak brute force and password policy work take?

Duration depends on how many realms, clients and federation sources are in scope, and on how much testing your change process requires. A single realm with local users and a few clients is a much smaller job than several realms with federated directories, custom authentication flows and staged approvals. No duration is stated here because the supplied facts do not give one. Ask for a timeline as part of the written scope, and confirm which parts depend on your approvals, such as signing off lockout thresholds, and which depend on your own test accounts being available.

What does our team need to provide before lockout and password rules are configured?

Your team provides decisions, access and people who can test. You need named realm owners who approve settings for their realm, test accounts that cover local and federated users, and a written decision on lockout thresholds, including whether lockout is temporary or permanent. You also need help desk procedures for unlocking accounts and resetting passwords, because those steps must match the policy. Access to the environment, change windows and a staging realm that mirrors production are usually required too. Confirm each item in the scope before work starts so that delays do not appear later.

Can an experienced internal team configure Keycloak lockout and password rules using the official documentation?

A competent internal team can usually do the configuration alone, using the Keycloak server administration guide, if it has time to test and document the result. The settings are documented in the official guide, and the work is mostly about deciding values and verifying behavior across realms and flows. Where teams often need outside help is in consistent results across many realms, testing federated logins, and producing change records that auditors can follow. Decide which of these your team can cover within its own schedule, and ask a partner to quote only the parts you choose to hand over.

What should we check after a Keycloak upgrade affects lockout behavior?

Review lockout events and login failure records after each upgrade, because defaults and stored data can change. The Keycloak 26.8 upgrade notes say login failures are persisted to the database by default, which means your team should confirm how that affects storage, reporting and retention. Check that thresholds still behave as approved, that federated users are handled correctly, and that help desk unlock steps still work. Plan these checks into the upgrade change process, and confirm with your own compliance team which records must be kept.

What recurring work follows after lockout and password rules go live?

Recurring work includes reviewing lockout events, revisiting thresholds and checking that password rules still match your policy. Keep a regular review of failed-login and lockout records, especially after upgrades, after new federation sources are added, and after new clients are onboarded. Review password history, expiry and blacklist settings when your policy changes. Decide who owns each review and how often it happens. A retainer for ongoing support, upgrades and testing is available from DeployOpen, and its scope and cost follow from a written proposal.

Does a Keycloak lockout and password policy need security testing?

Testing confirms that lockout and password rules work as approved, and it should cover both normal and attack-like login behavior. Plan test cases for repeated failed logins, temporary and permanent lockout, password history and expiry, blacklist enforcement, and federated users. DeployOpen runs security testing of applications, APIs and infrastructure, and that work can be scoped alongside configuration. Agree on the test scope, the environments used and how results are recorded before work begins, so that test evidence supports your change records.

How DeployOpen scopes, configures and supports Keycloak lockout and password rules

DeployOpen treats Keycloak brute force detection and password policies as a written, fixed-scope piece of work inside infrastructure you control. We define the lockout and password rules with your security team, configure them in your realms, test them against your login flows, and document them so your own operators can run them after handover.

How we scope

  • Agree in writing which realms, clients and user populations the lockout and password rules cover
  • Record the chosen lockout mode, failure thresholds and wait behavior for each login path
  • Confirm which password rules apply: history, expiry, blacklists and the hashing defaults in use
  • Identify federated users from LDAP or Active Directory whose passwords are managed outside Keycloak

How we build

  • Configure temporary or permanent lockout in a non-production realm before changing production settings
  • Set password policy rules and hashing parameters, then check them against your current user store
  • Test lockout behavior with scripted failed logins and confirm which events are recorded
  • Coordinate changes with help desk procedures so unlock and reset steps match the configured rules

How we hand over

  • Deliver a configuration record listing every brute force and password setting, with its value and owner
  • Document the unlock, reset and exception procedures your administrators will follow after handover
  • Walk your operators through the admin console steps and the test cases used during acceptance
  • Keep test scripts and the written scope so changes can be retested after future Keycloak upgrades

How we support

  • Review lockout and password settings when your authentication requirements or Keycloak release changes
  • Retest brute force and password rules as part of upgrade work planned with your team
  • Offer ongoing support, upgrades and continuous testing as a retainer after the fixed-scope work ends
  • Ask your auditors which evidence they expect for authentication controls before the scope is signed

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.