Summary
A flaw in Keycloak's JWT authorization grant preview feature allows disabled user accounts to be treated as active during token processing.
A remote attacker with low privileges can present a valid assertion token from an external identity provider and receive a JWT for a disabled user, leading to unauthorized access to protected resources.
Affected context
This vulnerability appears when Keycloak is configured with the JWT authorization grant preview feature enabled and integrated with one or more external identity providers.
The issue manifests specifically when a user has been disabled in Keycloak but still has a valid assertion token from an external IdP.
In such setups, the authorization server may issue JWTs without re-checking the disabled status of the mapped user account, allowing continued access despite local account deactivation.
Exploit preconditions
- Attack surface: Keycloak authorization endpoint handling JWT authorization grants.
- Required access: Ability to authenticate with an external identity provider and obtain a valid assertion token mapped to a disabled Keycloak user.
- Trigger point: Submission of a JWT-based authorization grant while the corresponding Keycloak user account is disabled.
- Why exploitation is possible: The token issuance flow trusts the external assertion and does not consistently enforce a local account-state check (disabled vs. enabled) before issuing a new JWT.
Why this happens
The underlying bug is an instance of CWE-284: Improper Access Control, where the authorization logic fails to fully enforce account state constraints.
In this case, the JWT authorization grant logic treats a valid external assertion as sufficient proof of eligibility without reevaluating whether the corresponding Keycloak user is disabled.
This separation between identity assertion validation and local account-state enforcement leads to a broken authorization check: deactivated accounts are not effectively blocked at the time of JWT issuance.
Potential impact
- Disabled users may continue to access applications and APIs protected by Keycloak.
- Attackers could maintain or regain access to sensitive resources even after an account has been deactivated.
- Compliance and audit controls can be undermined, as disabled accounts may appear inactive while still effectively usable.
- Security incident response actions that rely on disabling accounts may not fully contain compromised identities.
General mitigation guidance
Effective mitigation focuses on making account state checks authoritative in every token-issuance path and reducing reliance on external assertions alone.
Common defensive patterns include:
- Enforcing a mandatory local account-state verification step (enabled/disabled/locked) whenever issuing or refreshing JWTs, regardless of the grant type or external IdP assertions.
- Centralizing authorization decisions so that external identity tokens are treated as inputs to, not replacements for, local access-control checks.
- Designing clear deprovisioning workflows that ensure account disablement immediately propagates to all login and token-grant paths.
- Applying least-privilege principles in client scopes and roles so that any erroneously issued token carries minimal permissions.
- Hardening administrative and configuration access so preview or experimental features are only enabled after security review and testing.
How teams detect issues like this
Detection typically involves both configuration and behavioral analysis:
- Reviewing Keycloak configuration and realm settings to identify where JWT authorization grant preview features and external IdPs are active.
- Using static or configuration-based analysis to flag token flows that do not explicitly enforce local account-state checks before JWT issuance.
- Conducting focused code review on authentication and authorization handlers, looking for paths where user status (enabled/disabled) is not validated.
- Instrumenting logging and monitoring to capture token issuance for disabled or locked accounts and creating alerts when such events occur.
- Employing automated security testing or policy-as-code tools to simulate disabled-account scenarios and verify that token issuance is blocked.

