Skip to content

Keycloak brute force detection calculator

See how Keycloak’s brute force detection settings behave over a run of failed sign-ins: when the user gets locked, for how long, and how many guesses get through.

Runs in your browser. Nothing you paste is sent to us.

Settings

failureFactor. Keycloak’s default is 30.

waitIncrementSeconds. Default 60.

maxFailureWaitSeconds. Default 900 (15 minutes).

maxDeltaTimeSeconds. Default 43200 (12 hours).

quickLoginCheckMilliSeconds. Default 1000.

minimumQuickLoginWaitSeconds. Default 60.

What happens

10 passwords tried about 90 per hour longest lock 2 min

#1 at 0 s
Failedfailures counted: 1
#2 at 10 s
Failedfailures counted: 2
#3 at 20 s
Failedfailures counted: 3
#4 at 30 s
Failedfailures counted: 4
#5 at 40 s
Failed. Locked for 1 minfailures counted: 5
#6 at 50 s
Refused: locked for 50 s morefailures counted: 5
#7 at 1 min
Refused: locked for 40 s morefailures counted: 5
#8 at 1 min 10 s
Refused: locked for 30 s morefailures counted: 5
#9 at 1 min 20 s
Refused: locked for 20 s morefailures counted: 5
#10 at 1 min 30 s
Refused: locked for 10 s morefailures counted: 5
#11 at 1 min 40 s
Failed. Locked for 1 minfailures counted: 6
#12 at 1 min 50 s
Refused: locked for 50 s morefailures counted: 6
#13 at 2 min
Refused: locked for 40 s morefailures counted: 6
#14 at 2 min 10 s
Refused: locked for 30 s morefailures counted: 6
#15 at 2 min 20 s
Refused: locked for 20 s morefailures counted: 6
#16 at 2 min 30 s
Refused: locked for 10 s morefailures counted: 6
#17 at 2 min 40 s
Failed. Locked for 1 minfailures counted: 7
#18 at 2 min 50 s
Refused: locked for 50 s morefailures counted: 7
#19 at 3 min
Refused: locked for 40 s morefailures counted: 7
#20 at 3 min 10 s
Refused: locked for 30 s morefailures counted: 7
#21 at 3 min 20 s
Refused: locked for 20 s morefailures counted: 7
#22 at 3 min 30 s
Refused: locked for 10 s morefailures counted: 7
#23 at 3 min 40 s
Failed. Locked for 1 minfailures counted: 8
#24 at 3 min 50 s
Refused: locked for 50 s morefailures counted: 8
#25 at 4 min
Refused: locked for 40 s morefailures counted: 8
#26 at 4 min 10 s
Refused: locked for 30 s morefailures counted: 8
#27 at 4 min 20 s
Refused: locked for 20 s morefailures counted: 8
#28 at 4 min 30 s
Refused: locked for 10 s morefailures counted: 8
#29 at 4 min 40 s
Failed. Locked for 1 minfailures counted: 9
#30 at 4 min 50 s
Refused: locked for 50 s morefailures counted: 9
#31 at 5 min
Refused: locked for 40 s morefailures counted: 9
#32 at 5 min 10 s
Refused: locked for 30 s morefailures counted: 9
#33 at 5 min 20 s
Refused: locked for 20 s morefailures counted: 9
#34 at 5 min 30 s
Refused: locked for 10 s morefailures counted: 9
#35 at 5 min 40 s
Failed. Locked for 2 minfailures counted: 10
#36 at 5 min 50 s
Refused: locked for 1 min 50 s morefailures counted: 10
#37 at 6 min
Refused: locked for 1 min 40 s morefailures counted: 10
#38 at 6 min 10 s
Refused: locked for 1 min 30 s morefailures counted: 10
#39 at 6 min 20 s
Refused: locked for 1 min 20 s morefailures counted: 10
#40 at 6 min 30 s
Refused: locked for 1 min 10 s morefailures counted: 10
Realm settings (JSON)
{
  "bruteForceProtected": true,
  "permanentLockout": false,
  "failureFactor": 5,
  "waitIncrementSeconds": 60,
  "maxFailureWaitSeconds": 900,
  "maxDeltaTimeSeconds": 43200,
  "quickLoginCheckMilliSeconds": 1000,
  "minimumQuickLoginWaitSeconds": 60
}
A model, not Keycloak itself
This follows Keycloak’s classic temporary lockout formula. Recent versions add more choices, such as a lockout strategy and a number of temporary lockouts before a permanent one, which change the results. Check your settings on a test realm before you rely on them.

How to use it

  1. Enter the brute force settings from Realm settings, Security defenses.
  2. Describe the attack: how often it tries and how many times.
  3. Read when each try is refused or locks the account.
  4. Copy the settings as realm JSON.

What to know

With temporary lockout, a user who reaches the maximum number of failures is locked for the wait increment. The wait grows as failures keep coming, up to the maximum wait, and the count resets after the failure reset time.

Permanent lockout disables the user, which also lets anyone who knows a username lock that person out. Temporary lockout slows guessing without that risk.

The tool models the classic formula. Recent Keycloak versions add settings, such as a lockout strategy and a number of temporary lockouts before a permanent one, so check the result on a test realm.

What brute force detection does in Keycloak

Brute force detection counts failed sign-ins for each user. After too many failures, Keycloak locks that user for a while, or disables the account. It turns a fast guessing attack into a slow one.

It is off by default. You turn it on per realm, in the admin console under Realm settings, Security defenses, Brute force detection. The settings are stored on the realm, so they travel with a realm export and import.

This page explains each setting, how they combine, and how to read the calculator above. The calculator is a model, not Keycloak itself. The limits of that model are spelled out below, and they matter.

Why it matters in production

Any public sign-in page gets guessing traffic. Most of it tries common passwords against known or likely usernames. Without a limit, an attacker can try as fast as your servers answer.

Lockouts change the math. If each user can only fail a handful of times before a wait, the attacker gets a few guesses per hour instead of thousands. That makes a strong password policy far more effective.

Lockouts also have a cost. Every lock is a user who cannot sign in, and every support ticket about it costs time. The right settings slow attackers a lot while rarely touching real users.

The settings and their defaults

Each setting has a field in the realm JSON. These are the ones the calculator uses, with Keycloak’s defaults.

SettingRealm JSON fieldDefault
Max login failuresfailureFactor30
Wait incrementwaitIncrementSeconds60 seconds
Max waitmaxFailureWaitSeconds900 seconds (15 minutes)
Failure reset timemaxDeltaTimeSeconds43,200 seconds (12 hours)
Quick login checkquickLoginCheckMilliSeconds1,000 milliseconds
Minimum quick login waitminimumQuickLoginWaitSeconds60 seconds
Permanent lockoutpermanentLockoutoff
Brute force settings in a sample realm file
{
  "realm": "acme",
  "bruteForceProtected": true,
  "permanentLockout": false,
  "failureFactor": 5,
  "waitIncrementSeconds": 60,
  "maxFailureWaitSeconds": 900,
  "maxDeltaTimeSeconds": 43200
}

Max login failures

How many failures a user may have before a lock applies. Lower means fewer guesses per lock, and more locks for users who mistype.

Wait increment and max wait

The wait increment is the base lock time. As failures keep coming, the wait grows in steps of the increment, up to the max wait.

Failure reset time

If no failure happens for this long, the count goes back to zero. A long reset time means a slow attacker still builds up failures.

Quick login check

Failures that come faster than this window look like a script. If no other wait applies, Keycloak applies the minimum quick login wait instead.

Temporary and permanent lockout

With temporary lockout, a locked user can try again when the wait is over. With permanent lockout, the user is disabled and stays disabled until an admin enables the account.

Permanent lockout has a serious downside. Brute force detection counts failures per user, not per attacker. Anyone who knows a username can lock that person out by failing on purpose. For most realms, temporary lockout is the safer choice.

Recent Keycloak versions offer more choices here, such as a number of temporary lockouts before a permanent one, and a choice of how the wait grows. Check the options your version shows in the admin console.

What the calculator does and does not do

The calculator follows Keycloak’s classic temporary lockout formula. Newer versions can change when locks apply and how long they last. Always confirm your settings on a test realm before you rely on them.

The model works like this. After each failure, the wait is the wait increment times the number of failures divided by max login failures, rounded down, and capped at the max wait. A failure inside the quick login window gets the minimum quick login wait when no other wait applies. Failures reset after the failure reset time. Attempts during a lock are refused and not counted.

  • It simulates an attacker who tries every few seconds, for as many tries as you choose.
  • It shows each try: failed, failed and locked, or refused.
  • It reports how many passwords the attacker actually got to try, and about how many per hour.
  • It writes the settings as realm JSON you can copy.

It does not model newer lockout strategies, the number of temporary lockouts before a permanent one, or several attackers at once. It does not know whether your sign-in flow has other checks in front.

How to use the calculator

  1. Copy your realm’s values from Realm settings, Security defenses, or start from the filled-in example.
  2. Set how often the attacker tries and how many times.
  3. Read the badges: passwords tried, rate per hour and the longest lock.
  4. Scroll the list of tries to see when locks start and how they grow.
  5. Change one value at a time and compare the passwords tried.
  6. Copy the realm JSON once you are happy, then test it on a test realm.

Reading the results

The number that matters most is passwords tried. It is the number of real guesses the attacker made against one account in the time you simulated. Refused tries cost the attacker time but test nothing.

Compare that number with your password policy. If users must pick long passwords and common ones are banned, a few dozen guesses a day is very little. If the policy is weak, even a small number of guesses can find a common password.

Then look at the longest lock. A long lock slows attackers, but it is also what a real user faces after a bad morning. If the max wait is reached quickly, the attacker settles into one guess per max wait, and that rate is what you are really choosing.

Use cases

First production deploy

Turn brute force detection on before launch. Use the calculator to pick values that allow a few honest mistakes but cap guessing at a low rate.

Security audit

Reviewers often ask how many guesses an attacker gets per account per day. Enter the realm’s values and a steady attack, and read the rate. Note the model’s limits in the audit notes.

Upgrade from an older version

Lockout options have grown over recent releases. After an upgrade, open the brute force settings in the console and check which mode the realm uses, then test it.

LDAP and Active Directory users

Directories often have their own lockout policy. Two lockouts stacked on top of each other can lock users out of both. Decide which one leads, and set the other more loosely.

Common problems and fixes

A user is locked and cannot sign in

Open the user in the admin console and clear the lock, or wait for it to expire. Through the admin API, delete the user’s entry under attack-detection.

Clearing one user’s failures in the sample realm acme
curl -X DELETE \
  "https://auth.example.com/admin/realms/acme/attack-detection/brute-force/users/<user-id>" \
  -H "Authorization: Bearer $TOKEN"

Many users locked at once

A wave of locks often means one password tried against many usernames. Check login events for LOGIN_ERROR and the addresses they come from, and block at the network edge.

Users do not know they are locked

The sign-in page may show a generic error, so users think they mistyped. Login events record the reason, such as user_temporarily_disabled, which helps support answer quickly.

Locks never seem to clear

With a long failure reset time, a user who fails now and then keeps a high count. Each new failure then locks at once. Shorten the reset time, or clear the user’s failures.

Security notes

  • Per-user lockouts do not stop one password tried against many users. Add rate limits at the proxy as well.
  • Permanent lockout lets anyone who knows a username lock that user out.
  • Save login events, so you can see attacks and explain locks to users.
  • Protect admins with a second factor, not only with lockouts.

Best practices

  • Turn brute force detection on in every production realm.
  • Prefer temporary lockout with a modest max wait.
  • Keep max login failures low enough to cap guessing, high enough for honest typos.
  • Keep the settings in your realm file and version control.
  • Test the settings on a test realm after every upgrade.
Questions

Frequently asked questions

Is brute force detection on by default in Keycloak?

No. Turn it on per realm under Realm settings, Security defenses, Brute force detection. The setting is saved on the realm as `bruteForceProtected`.

How do I unlock a user locked by brute force detection?

Open the user in the admin console and turn the lock off, or wait for the lock to expire. Through the admin API, delete the user’s entry under `attack-detection/brute-force/users`.

What are Keycloak’s default brute force settings?

Max login failures 30, wait increment 60 seconds, max wait 15 minutes and failure reset time 12 hours. Permanent lockout is off.

Should I use permanent or temporary lockout?

Temporary, in most cases. Failures are counted per user, so with permanent lockout anyone who knows a username can lock that user out. A disabled user then needs an admin to get back in.

Does Keycloak brute force detection block IP addresses?

It counts failures per user, not per address. To limit how fast one address can try, add rate limits at your proxy or load balancer.

Why does a locked user only see invalid credentials?

The sign-in page may not say that the account is locked. Check the user’s login events, which record the reason, or the user’s page in the admin console.

Does brute force detection apply to LDAP users?

Yes, Keycloak counts failed sign-ins for federated users too. Your directory may also lock accounts, so decide which lockout leads and set the other more loosely.

How accurate is this calculator?

It follows Keycloak’s classic temporary lockout formula. Recent versions add options that change the result, so confirm your settings on a test realm before you rely on them.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.