MEDIUM 6.5

CVE-2026-4629: Keycloak Privilege Escalation via Role Mapper Injection

Keycloak contains a privilege escalation vulnerability that allows administrators with client management permissions to grant themselves unauthorized access. A user with the `manage-clients` permission can inject a role mapper that artificially adds the `realm-admin` role to authentication tokens, bypassing normal access controls and gaining full administrative privileges over the Keycloak realm. This attack requires existing elevated privileges but results in complete administrative compromise.

Source data · NVD / CISA · public domain

CVSS
3.1 · 6.5 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N
Weaknesses (CWE)
CWE-266
Affected products
1 configuration(s)
Published / Modified
2026-06-30 / 2026-08-05

NVD description (verbatim)

A flaw was found in Keycloak. A highly privileged user with `manage-clients` permission can exploit this vulnerability by injecting a hardcoded role mapper into any client. This action allows the user to bypass existing scope restrictions and inject the `realm-admin` role into generated tokens, resulting in privilege escalation and full administrative access to the realm.

4 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

CVE-2026-4629 is a privilege escalation vulnerability in Keycloak arising from insufficient validation of role mapper configuration. An authenticated user holding `manage-clients` permission can programmatically inject a hardcoded role mapper into any client application. The injected mapper manipulates token generation logic to unconditionally assert the `realm-admin` role in issued tokens, circumventing scope restrictions and attribute-based access control policies. The vulnerability maps to CWE-266 (Improper Privilege Management) and stems from a trust boundary violation between client configuration endpoints and token assertion mechanisms.

Business impact

This vulnerability enables insider threats and compromised administrator accounts to escalate privileges without detection. An attacker with client management rights—such as a rogue service administrator or operator with delegated permissions—can assume full realm administrative capabilities, including user provisioning, policy modification, secret rotation, and audit log manipulation. Organizations relying on Keycloak's role-based access control (RBAC) for multi-tenant isolation face significant risk if a lower-privileged account is breached or an insider has malicious intent.

Affected systems

Red Hat Build of Keycloak is confirmed affected. Other Keycloak distributions (community, vendor-supplied) are likely affected unless patched; verify with your specific distribution's security advisory. The vulnerability impacts all realms within an affected instance and all client applications that trust tokens issued by that realm.

Exploitability

While exploitability requires high privileges (`manage-clients` permission), the attack is straightforward once that permission is held. No user interaction is needed, and the vulnerability is accessible over the network. The barrier to exploitation is high privilege level, not technical complexity. If client management access is available to delegated administrators, service accounts, or shared credentials, the risk increases significantly.

Remediation

Apply security updates released by your Keycloak vendor (Red Hat, distributions, or community project). Verify patch availability in your vendor's security advisory—specific version numbers must be confirmed against official guidance. Until patching is possible, restrict `manage-clients` permission to only the most trusted administrators and enable comprehensive auditing of client configuration changes. Consider network segmentation to limit who can interact with Keycloak administration endpoints.

Patch guidance

Contact your Keycloak vendor or check their security advisory portal for available patches. For Red Hat Build of Keycloak, consult Red Hat's customer portal or publicly available security advisories. Apply patches to all Keycloak instances in your environment, including development and staging environments that may be used to test client configurations. Verify patch application by confirming version numbers match vendor guidance and testing role mapper injection is rejected on updated systems.

Detection guidance

Monitor Keycloak's audit logs for client configuration modifications, particularly changes to mappers or protocol configurations. Alert on any client receiving a new role mapper claiming to assert realm-admin or other high-privilege roles. Review client credentials and service account permissions to identify accounts holding `manage-clients` privileges. Inspect active tokens (via token introspection or logs) for unexpected realm-admin role assertions originating from standard client applications. Correlate suspicious role additions with authentication events from the same source IP or account.

Why prioritize this

Although marked MEDIUM severity due to the high privilege requirement, organizations should treat this as priority if client management is delegated, if service accounts have these permissions, or if administrator account compromise is a credible threat model. The consequence—full realm compromise—is severe, and the privilege prerequisite can be satisfied through common delegation patterns in larger deployments.

Risk score, explained

CVSS 3.1 score of 6.5 (MEDIUM) reflects high privileges required (PR:H) balanced against high impact on confidentiality and integrity (C:H, I:H) with no availability impact (A:N). Network accessibility (AV:N) and low attack complexity (AC:L) elevate the score. The rating assumes the attacker must already hold privileged credentials; however, the severity of impact—full administrative compromise—warrants close attention regardless of the numeric score.

Frequently asked questions

Can an attacker without `manage-clients` permission exploit this vulnerability?

No. This vulnerability requires authentication and the specific `manage-clients` permission. An unauthenticated attacker or a user without this permission cannot exploit it. However, if you delegate client management to multiple administrators, service accounts, or automation, your exposure increases.

Does patching require a realm restart or token revocation?

Consult your vendor's patch advisory for specific deployment steps. Some security fixes require realm restarts or cache invalidation. Token revocation of existing tokens may be prudent after patching to invalidate any tokens generated by exploited clients, though this depends on your vendor's guidance.

How can I tell if this vulnerability has been exploited in my environment?

Search audit logs for unexpected client mapper additions or modifications, particularly those adding role assertions. Check issued tokens for realm-admin roles from clients that should not have them. Enable verbose logging on token generation if supported. Baseline your normal client configurations and alert on deviations.

What if I don't use Keycloak's client management features delegated to non-primary administrators?

Your exposure is reduced but not eliminated. Any account with `manage-clients` permission—including service accounts used for automation—poses a risk if compromised. Maintain least-privilege principles for all accounts with this permission and monitor their activity closely.

This analysis is based on available vulnerability data as of the publication date. Specific patch version numbers, affected minor versions, and complete product coverage must be verified against official vendor security advisories. Organizations should independently validate applicability to their deployed Keycloak versions and distributions. This summary does not constitute professional security advice; consult your security team and vendor guidance for your specific environment. Source: NVD (public-domain), retrieved 2026-08-09. Analysis generated by SEC.co (claude-haiku-4-5).