CVE-2025-9162
Java vulnerability analysis and mitigation

Overview

CVE-2025-9162 is a variable injection vulnerability in org.keycloak/keycloak-model-storage-services that allows a highly privileged attacker to expose sensitive environment variables — such as database passwords — by crafting malicious realm import documents. The KeycloakRealmImport custom resource substitutes placeholders within imported realm documents that can reference environment variables, enabling injection of sensitive data into the Keycloak environment. Affected versions are keycloak-model-storage-services < 26.2.9 and >= 26.3.0, < 26.3.4. The vulnerability was reported on August 19, 2025, and publicly disclosed on August 21, 2025, with patches released in September–October 2025. It carries a CVSS v3.1 base score of 4.9 (Medium) (Red Hat CVE, Github Advisory).

Technical details

The root cause is classified as CWE-526 (Cleartext Storage of Sensitive Information in an Environment Variable). The vulnerable code resides in AbstractFileBasedImportProvider.java, where placeholder substitution during realm import can resolve environment variable references embedded in a crafted realm document (Red Hat Bugzilla, Github Advisory). An attacker with administrative (high-privilege) network access can supply a specially crafted realm document containing environment variable references (e.g., referencing $DB_PASSWORD), which are then substituted and potentially exposed in the imported realm configuration. No user interaction is required, and the attack complexity is low, but exploitation is gated by the requirement for high privileges.

Impact

Successful exploitation results in a high confidentiality impact — specifically, the exposure of sensitive environment variables such as database credentials or other secrets accessible to the Keycloak process. There is no direct integrity or availability impact. In environments where Keycloak has access to secrets via environment variables (e.g., Kubernetes secrets mounted as env vars), this could lead to credential theft and potential lateral movement to backend databases or other integrated services (Github Advisory, Red Hat CVE).

Exploitability

No public proof-of-concept exploit code or in-the-wild exploitation has been reported for CVE-2025-9162. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. The EPSS score is approximately 0.028–0.041%, placing it in the 13th percentile for exploitation likelihood within 30 days (Github Advisory). Exploitation requires high-privilege access (e.g., Keycloak administrator), which significantly limits the attack surface.

Exploitation steps

  1. Gain administrative access: Obtain Keycloak administrator credentials or access to the Kubernetes/OpenShift cluster with permissions to create KeycloakRealmImport custom resources.
  2. Craft a malicious realm document: Prepare a realm JSON/YAML import document containing placeholder references to sensitive environment variables, such as ${DB_PASSWORD} or ${SECRET_KEY}, in fields that will be stored or returned (e.g., realm attributes, client secrets, or display names).
  3. Submit the realm import: Use the Keycloak Operator's KeycloakRealmImport custom resource or the Keycloak admin API to trigger the import of the crafted realm document.
  4. Retrieve substituted values: After import, query the Keycloak admin API or inspect the imported realm configuration to retrieve the resolved values of the environment variable placeholders, exposing sensitive secrets (Red Hat Bugzilla, Github Advisory).

Indicators of compromise

  • Logs: Keycloak server logs showing realm import operations (KeycloakRealmImport) initiated by unexpected or unauthorized admin accounts; audit log entries for realm creation or update events with unusual timing.
  • Kubernetes/OpenShift: Unexpected KeycloakRealmImport custom resource objects created in the Keycloak namespace; review of kubectl get keycloakrealmimport -n <namespace> for unrecognized entries.
  • File System: Realm export files or import documents containing environment variable placeholder syntax (e.g., ${VAR_NAME}) in unexpected locations.
  • Network: Unusual Keycloak admin API calls (e.g., POST /admin/realms) from unexpected source IPs or service accounts (Red Hat Bugzilla).

Mitigation and workarounds

Red Hat has released patched versions addressing this vulnerability: keycloak-model-storage-services 26.2.9 and 26.3.4. For Red Hat build of Keycloak, the fixes are included in RHSA-2025:15336 (version 26.0.15), RHSA-2025:16399, and RHSA-2025:16400. Organizations should upgrade to Keycloak 26.2.9+ or 26.3.4+ as soon as possible. As a workaround, restrict administrative access to Keycloak and limit who can create or submit KeycloakRealmImport custom resources in Kubernetes/OpenShift environments (Github Advisory, RHSA-2025:15336).

Community reactions

Red Hat classified this vulnerability as Moderate severity and issued multiple security advisories (RHSA-2025:15336 through RHSA-2025:16400) covering both standalone and OpenShift container deployments of Keycloak. The vulnerability was credited to researcher Ankush-Pathak. Coverage has been limited to standard vulnerability aggregators and German security news outlet pro-linux.de; no significant broader community or social media discussion has been observed (RHSA-2025:15336, Github Advisory).

Additional resources


SourceThis report was generated using AI

Related Java vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-54148HIGH8.1
  • Java logoJava
  • org.http4k:http4k-security-digest
NoYesAug 17, 2026
CVE-2026-53752HIGH7.5
  • Java logoJava
  • org.docx4j:docx4j-core
NoYesAug 17, 2026
CVE-2026-53659HIGH7.5
  • Java logoJava
  • org.http4k:http4k-core
NoYesAug 17, 2026
CVE-2026-54147MEDIUM6.5
  • Java logoJava
  • org.http4k:http4k-security-digest
NoYesAug 17, 2026
CVE-2026-59903MEDIUM6.5
  • Java logoJava
  • netty
NoYesAug 17, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management