Keycloak MFA recovery: what happens when a user loses their authenticator
When a user loses a phone or security key after MFA is enabled, or an administrator is locked out, Keycloak gives you three levers: recovery codes that the user can spend without help, admin removal of OTP and WebAuthn credentials so the user can enroll again, and required actions that force re-enrollment at the next sign-in. Decide how these work before you turn MFA on for anyone. The moment a second factor is mandatory, every lost device becomes a help desk ticket unless the recovery path already exists. Treat the recovery flow as a designed part of the authentication flow, reviewed with the same people who approve the MFA policy, not as a runbook written after the first lockout.
The design questions are specific. Decide which factors can be reset by an administrator and which must be re-proven by the user, because resetting a WebAuthn credential or OTP secret is effectively handing over the account's second factor. Decide whether recovery codes are issued at enrollment, how users store them, and what happens when they run out. Confirm in your Keycloak version how recovery codes are generated, displayed and regenerated in the account console and whether a user can regenerate them without signing in again. Map each path to the audit trail you need, because admin credential removals and re-enrollments are the events an auditor will ask about first.
Plan the administrator case separately. An administrator who loses the only enrolled factor must not depend on the same flow that serves regular users, and the break-glass account used to recover administrators needs its own controlled second factor and logged use. Ask your team to test each path end to end before rollout: a lost phone, a lost security key, an exhausted set of recovery codes and a locked administrator. The exact behavior of required actions and credential removal in your release should be confirmed in the Keycloak server administration guide and against a staging realm, not assumed from older documentation.
Which recovery path fits which lost-device situation
This is the lowest-risk situation. The user still holds one or more unused recovery codes generated when they enrolled a second factor, so they can complete sign-in without help from an administrator. The main risk is not the login itself but what follows: a code that was photographed, stored in a shared note, or reused after the user already consumed it can give an attacker the same access. Plan for the user to sign in, then immediately re-enroll a new authenticator and generate a fresh set of codes.
- Sign in with a code: Confirm in your target version that the recovery code option appears on the second-factor screen for the flow you run, and test it with a real account before go-live.
- Rotate the set: After a code is used, have the user regenerate the full set in the account console and store the new codes in a password manager or a sealed envelope held by an approved custodian.
- Revoke the old authenticator: Remove the lost device's credential so a stolen phone cannot be used alongside the codes.
- Check for reuse: Review login events for repeated code use, which can indicate the codes were shared.
- Confirm the code count and format: Verify with the vendor documentation for your version how many codes are generated and how long they remain valid.
Before relying on this path, confirm in your environment that the recovery-code step is present in every flow that requires a second factor.
Here the user has lost one authenticator but still controls another that is registered to the same account, such as a backup security key, a second OTP app, or a passkey on a laptop. Recovery is a self-service sign-in with the working device, followed by removal of the lost credential. The risk is that a second device is sometimes registered by a previous help desk action, or by an attacker who obtained a session, so the registered factors themselves need review before they are trusted.
- Sign in with the other device: The user authenticates with the registered backup factor and then opens the account security settings.
- Remove the lost credential: Delete the OTP or WebAuthn entry for the lost device so it can no longer satisfy a second factor.
- Register a replacement: Enroll a new device during the same session so the user does not fall back to a weaker method later.
- Review recent changes: Check when the backup factor was added and who added it, especially if it was added recently.
- Confirm the self-service screens: Verify in the target Keycloak version which account pages allow credential deletion and whether the user needs to re-authenticate first.
Confirm that your policy permits users to delete their own factors, because that setting determines whether this path needs an administrator at all.
In this situation the user has no recovery codes, no second device, and no way to complete the factor. Every self-service route is closed, so the account needs an administrator or help desk to reset the credential. This is the highest-risk path for social engineering, because the request looks like a routine reset. The verification of the requester's identity before any change is the control that matters most, and it should be defined in advance rather than improvised during the call.
- Verify identity out of band: Confirm the request through a channel the attacker does not control, such as a callback to a number already on file or a manager approval.
- Remove the credential: Use the admin console to delete the OTP or WebAuthn entry for the user.
- Set a required action: Assign the enrollment action so the user must register a new factor at next sign-in, and set a short window for completion.
- Log the change: Record who requested the reset, who approved it, and the time, and keep that record with the ticket.
- Confirm the reset behavior: Check in your target version how the admin console and Administration REST API handle credential deletion and required actions, and test the sequence in a non-production realm.
Agree the identity verification standard with your security team before the first reset is requested.
An administrator who cannot complete MFA cannot manage the realm, so this case needs a path that does not depend on the locked account. The risk is twofold: recovery itself is a privileged action, and a poorly designed break-glass account can become a permanent backdoor. Recovery should use a separately controlled account or a documented bootstrap procedure, with each step recorded and reviewed afterward.
- Use a break-glass account: Keep a separately credentialed administrator, stored under dual custody, that is not used for daily work and is tested on a schedule.
- Reset from another administrator: Another administrator in the master realm can clear the locked account's OTP or WebAuthn credential and trigger re-enrollment.
- Use the bootstrap path only with approval: If no administrator can sign in, the documented bootstrap-admin procedure in your version may be needed. Confirm its current steps against the server administration guide before use.
- Record and review: Log every recovery action on administrator accounts and review them with the security team.
- Rehearse before you need it: Test the procedure in staging, since a first attempt during an outage is the wrong time to find a missing step.
Confirm the exact bootstrap and credential-reset commands for your release, because administrator recovery steps change between versions.
Recovery options in Keycloak and when each fits
This table compares the five recovery paths a Keycloak team can use when a user loses an OTP authenticator or WebAuthn key, showing who acts, what each path protects against and its main trade-off. Read it by first asking who can prove identity, then choosing the least privileged path that still gets the user back in.
| Option | Who acts | What it protects against | Main trade-off |
|---|---|---|---|
| Recovery codes | The user, using codes saved in advance | Lockout without help desk involvement, so a lost phone does not stop sign-in | Codes are a second secret the user must store safely; a leaked or lost code list weakens the second factor |
| Admin removal of OTP credential | A Keycloak administrator in the admin console or Admin REST API | A user who cannot use an authenticator app but has a verified identity to the help desk | Each removal is a manual task, and the admin must verify the user before acting |
| Admin removal of WebAuthn credential | A Keycloak administrator in the admin console or Admin REST API | A lost or replaced security key or passkey device, without a password fallback | The user must enroll the replacement before the next sign-in; the help desk carries the identity check |
| Required action re-enrollment | The user, after an administrator sets the required action | Ensures the user registers a new factor before gaining access, so the removal does not leave the account with no second factor | The user still needs a working sign-in path to reach the enrollment step, so it pairs with another option |
| Help desk identity verification | Help desk staff, following your written verification procedure | Social engineering attempts to reset MFA for a caller who is not the account owner | Depends on staff process and training; Keycloak does not verify the caller's identity on its own |
Setting up a recovery process before users need it
This sequence builds the recovery path in a non-production realm first, so that when a user loses a device the help desk already knows which check to run, which credential to reset and which required action brings the user back into MFA.
Decide which recovery methods you will offer
Before touching any configuration, the security lead and identity team agree which recovery methods are allowed for each user group, such as recovery codes for standard users and help desk reset for administrators. Record the decision in a short written standard that names the approving owner. The step is done when every user group has a named recovery method and an owner who signed off.
Enable recovery codes in the authentication flow
In the admin console, the identity engineer adds the recovery codes step to the browser or MFA flow and sets the matching policy and required actions in a non-production realm. Confirm the step appears in the flow diagram in the expected order after the OTP or WebAuthn step. The check is a test login that reaches the recovery code prompt and shows the codes generated at enrollment.
Confirm required actions for re-enrollment
The identity engineer sets up the required actions that send a user back through OTP or WebAuthn registration after an admin clears a credential. Use a test user, remove their OTP credential from the admin console and sign in again. The check is that the user is prompted to enroll a new factor at next login and cannot reach the application without doing so.
Write the admin reset runbook
The platform team writes a step-by-step runbook covering how an administrator finds the user, removes the lost OTP or WebAuthn credential, sets the re-enrollment required action and records the reason in the ticket. Include the admin events and login failure records the team should review. The runbook is complete when a second administrator can follow it in the test realm without asking questions.
Define help desk identity checks
Security and help desk leads agree which checks must pass before a reset is performed, such as verifying the caller through a manager callback or a known channel, and what the help desk must never accept as proof. Write these checks into the ticket template. The output is a signed checklist that the help desk uses for every reset request, reviewed with a sample of recent tickets.
Test every recovery path in a non-production realm
The QA or security engineer runs each path with test accounts: recovery code use, admin credential reset, re-enrollment, rejected help desk request and locked administrator recovery through the bootstrap path. Record the result of each case, including the expected log entries. The step is done when every path passes and each failure has a fix and a retest.
Promote the approved configuration to production
The platform team moves the realm configuration to production through the same versioned process used for other changes, then repeats a smoke test with a dedicated test account. Confirm that the runbook, checklist and test results are stored with the change record. The check is a successful production test login and a stored evidence package the auditors can review.
How help desk identity checks prevent recovery from becoming an attack path
An MFA reset is one of the most valuable things an attacker can ask a help desk for. Once a second factor is removed, the password alone is enough to sign in, and a convincing caller who claims to have lost a phone can turn a single phished password into full access. Recovery therefore needs its own verification path, separate from the path a user takes to sign in, and the help desk should never be able to reset a factor on the strength of a caller's word alone. The exact checks are a policy decision that your organization must set, based on the sensitivity of the applications behind Keycloak and the roles of the people involved.
A workable baseline usually combines three controls. First, out-of-band confirmation: the help desk calls back on a number already stored in the directory or HR system, never on a number the caller supplies, or sends a one-time approval to a channel the user already controls. Second, manager or application owner approval for resets of privileged accounts, so that no single agent can clear a factor for an administrator. Third, verified contact details, meaning the help desk compares what the caller knows against records that predate the request. Confirm with your own identity and HR owners which records are current enough to rely on, and whether your help desk tooling can enforce these steps rather than relying on agents to follow a script.
Log every reset with the requester, the verifier, the approver, the time, the credential type removed and the reason, and review those entries on a fixed schedule. In Keycloak, the admin events and event logging you enable should capture credential removal and required action changes, so that the help desk ticket and the server record can be matched. Treat unexpected reset patterns, such as several resets for one user in a short period or resets outside working hours, as security incidents to investigate, not as routine tickets.
Security risks in MFA reset and how to contain them
Every MFA reset is a deliberate hole in your strongest login control, so the reset path itself becomes an attack target. The cards below cover the risks that most often turn a recovery workflow into an account takeover path, and the containment action for each one in a Keycloak deployment.
Help desk social engineering
An attacker who convinces a help desk agent that they are a locked-out employee can have an OTP or WebAuthn credential removed from the real account. Contain this with a written identity check that the agent cannot skip, such as verification through a callback to a number already on file or a manager approval in your ticketing system. Test the script with staff using realistic pretext calls, and record every exception to the script.
Keycloak docsRecovery codes stored insecurely
Recovery codes work as a second factor on their own, so a copy saved in a shared drive, a chat message or a screenshot is as useful to an attacker as the password. Tell users to store them in a password manager or offline, and do not let them appear in support tickets or screen shares. Decide whether your realm policy allows recovery codes at all for administrator accounts, and confirm how users are shown and regenerate them in your Keycloak version.
Reset rights held by too many admins
When every realm administrator can clear OTP or WebAuthn credentials, the reset right is spread across people who never needed it. Limit credential management to a small help desk role in the realm, and keep realm-wide administrator rights separate. Review who holds that role on a fixed schedule and remove it when someone changes jobs.
No audit trail for resets
A credential removal with no record of who requested it, who approved it and which device replaced it cannot be investigated after an incident. Confirm that admin events and login events are stored in a durable backend and forwarded to your log platform, and that each reset links to a ticket ID. Ask your auditors which evidence they will sample before you finalize the format.
Recovery path bypasses admin MFA
A help desk reset or a recovery code can become a way around the phishing-resistant factor that administrators must use. Keep administrator accounts on a separate authentication flow, exclude their recovery paths from ordinary user flows, and require a second approver for any reset on an admin account. Test this path explicitly, because a reset that works for a standard user may still succeed for an administrator.
Stale credentials after reset
If an old authenticator remains registered after a reset, or a lost key is never removed, the device that was reported missing still signs in. After every reset, confirm that the old credential no longer appears on the user's account, and set a required action so the user enrolls the replacement before the next sign-in. Check this result in the admin console or the Administration REST API rather than trusting the ticket status.
Decision path from lost factor to restored sign-in
The path starts when a user reports a lost authenticator and first checks for saved recovery codes. If none are available, the help desk verifies the person through an independent channel before an administrator removes the OTP or WebAuthn credential in Keycloak. The user then signs in and completes required action re-enrollment, and the event is logged. Locked-out administrators follow a separate branch that uses a break-glass account, so the team should confirm that path before it is needed.
Branches for lost user factors and locked-out administrators, with logging at each outcome.
What to confirm in your environment before relying on recovery
Recovery design in Keycloak depends on details that differ between releases, authentication flows and deployment models. The cards below list what to test on your own Keycloak build before a help desk or runbook depends on it, because a recovery path that works in a lab may behave differently in your flows, realms and federated directories.
Recovery code behavior per flow
Confirm which browser flows, required actions and custom authenticators in each realm accept recovery codes, and whether a code used in one flow is accepted in another. Check how many codes each user receives, how a regenerated set invalidates the old one, and whether codes are shown again after enrollment. Test each flow with a real user account, not only the admin console view.
Keycloak server admin docsConsole or Admin REST API for resets
Determine whether your help desk will reset OTP and WebAuthn credentials through the admin console or through the Administration REST API. The API path needs a service account or admin token with the right realm role, and its calls should be logged and reviewed. Confirm that the role holding this permission cannot also change the user's password or email address without a second approval.
Bootstrap and break-glass admin access
Confirm how the bootstrap admin account is created, where its credentials are stored, and whether it still exists after the first admin is set up. Test that a break-glass path works when the normal admin's second factor is lost, and that using it raises an alert. A locked-out administrator in the master realm can affect every realm, so this path needs its own runbook.
Sessions and tokens issued before a reset
Check whether existing user sessions and refresh tokens survive an OTP or WebAuthn credential reset. A credential reset does not necessarily end active sessions, so a stolen session may outlive the device it was tied to. Decide whether a reset should also trigger logout of all sessions, and test that token lifetimes and revocation behave as your policy requires.
Federated and brokered users
For users who sign in through LDAP, Active Directory, or an external identity provider, confirm which second factor, if any, Keycloak itself controls. A reset in Keycloak may have no effect when the upstream provider enforces its own MFA, and recovery may have to happen there. Document which system owns each user's factors so the help desk does not reset the wrong one.
Keycloak server admin docsQuestions teams ask before designing Keycloak MFA recovery
What drives the effort of Keycloak MFA recovery design?
The effort depends on how many recovery paths your users need and how many realms, clients and user populations those paths touch. A single realm with TOTP for employees is a small design. Several realms with WebAuthn, passkeys, smart cards and different help desk tiers multiply the decisions. The main drivers are the number of credential types in use, whether users self-serve recovery or depend on staff, how identity is verified before a reset, what the audit trail must show, and how many custom flows or themes must change. Ask any provider to list each credential type and each recovery path in the written scope before quoting.
Can our own team build Keycloak MFA recovery internally?
Often yes, if your team already runs Keycloak in production and has people who understand authentication flows, required actions and admin REST calls. The work includes designing the flows, writing the help desk runbook, testing every recovery path, and documenting evidence for auditors. Teams without recent Keycloak administration experience usually spend most of their time learning the product while testing, which is where mistakes such as an accidental MFA bypass tend to appear. Consider whether the same people can also review the design and run the test cases, since one team building and checking its own work is a common gap.
What does the work need from our identity and help desk staff?
Recovery design needs decisions from people outside the identity team. Identity engineers own the Keycloak configuration, required actions and credential policies. Help desk leads must agree on what evidence a caller provides, such as manager confirmation, a callback to a registered number, or an in-person check with photo identification. Security and compliance staff define which recovery events must be logged and who approves exceptions. Finally, the people who will take the calls need to walk through the runbook so the steps match what the admin console actually shows them. Without these decisions, the technical design will work but will be applied inconsistently.
How long does a recovery design review usually take?
The duration depends on scope, and no fixed figure applies to every organization. A review of one realm with one or two credential types is shorter than a review covering several realms, external identity providers, smart card login and a tiered help desk. Time is spent on inventorying current users and credentials, mapping who can approve resets, testing each path in a non-production realm, and revising the runbook after testing. Ask for the review's deliverables and milestones in writing, and confirm which of your internal approvals and change windows will add elapsed time.
Are recovery codes enough on their own for MFA recovery?
No. Recovery codes help a user who still has a list of them, but they are one part of the recovery design. Users lose printed lists, store them insecurely, or use them all. Recovery codes also do not help a user who lost a device and never saved codes, so an administrator reset path and re-enrollment through required actions are still needed. Each path should have a clear owner, a verified identity check and an audit record. For privileged accounts, recovery codes alone are usually not the right answer, and the design should route those users through a stricter process.
How should we size the help desk process for MFA recovery?
Size the process from your own demand data rather than from a generic ratio. Start by counting how many users currently have each credential type, how often devices are lost or replaced, and which recovery requests reach the help desk today. Then estimate how many of those requests can be handled by self-service recovery and how many need staff. Staffing also depends on the verification steps: a callback check takes longer than a manager confirmation. Build a small pilot, measure the handling time for real tickets, and use that measurement to plan coverage, escalation and after-hours access.
What should we confirm about Keycloak features before designing recovery?
Confirm the exact Keycloak version you run and the credential types enabled in each realm, because the admin console and required action options change between releases. Check that recovery codes, OTP and WebAuthn credential management are available in your version and that your administrators can reset each credential type. Also confirm how your login events and admin events are stored and retained, since auditors will ask for them. The current release line is documented on the project site, so verify your version against the server administration guide before you write the runbook.
How DeployOpen scopes and delivers Keycloak MFA recovery
DeployOpen scopes Keycloak MFA recovery as a fixed-scope engagement, with the recovery paths, the realms and clients they cover, and the deliverables agreed in writing before work starts. The written scope names which recovery methods are in use (recovery codes, admin reset of OTP and WebAuthn credentials, required actions for re-enrollment, and the help desk verification steps), which administrator roles may perform each action, and which realms and authentication flows are included. A quote follows from that document, so the reader can compare the scope against their own team's capacity before committing.
The work is carried out in the client's own Keycloak, in their infrastructure, so the configuration, admin accounts and audit trail stay under their control. Each recovery path is tested end to end: a user who has lost an OTP device or a security key, a user who has used a recovery code, an administrator locked out of the master realm, and a help desk request that should be refused. The tests confirm that a recovered session cannot bypass the MFA policy that applies to the account, and that admin actions appear in the event log. Ask whether the test plan includes negative cases, since a recovery path that works but can be abused is the failure that matters most.
Deliverables typically include the configured flows and required actions, a help desk verification procedure, and runbooks for the break-glass administrator and the reset of each credential type. Ongoing changes, such as a new authenticator type or a new realm, are handled through a retainer, which covers re-testing recovery paths after Keycloak upgrades. Confirm with DeployOpen which runbooks and retests are fixed in the initial scope and which are recurring, and ask who owns the runbooks after handover.

