CVE-2025-9162

4.9 MEDIUM

📋 TL;DR

This vulnerability in Keycloak's realm import functionality allows attackers to inject malicious content via crafted realm documents that reference environment variables. The flaw enables injection attacks during the import process, potentially leading to unintended consequences in the Keycloak environment. Organizations using Keycloak with realm import features are affected.

💻 Affected Systems

Products:
  • Keycloak
  • Red Hat Single Sign-On
Versions: Keycloak versions prior to patches; specific versions detailed in Red Hat advisories
Operating Systems: All platforms running affected Keycloak versions
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability requires realm import functionality to be used; default installations may be vulnerable if this feature is enabled.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete compromise of Keycloak environment through arbitrary code execution or data manipulation, potentially leading to authentication bypass or privilege escalation.

🟠

Likely Case

Limited data manipulation or configuration changes within imported realms, potentially disrupting authentication flows or exposing sensitive configuration data.

🟢

If Mitigated

No impact if proper input validation and environment variable restrictions are in place, or if realm import functionality is disabled.

🌐 Internet-Facing: MEDIUM - Exploitation requires access to realm import functionality, which may be exposed to authenticated users or administrators.
🏢 Internal Only: MEDIUM - Internal attackers with realm import privileges could exploit this to manipulate Keycloak configurations.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires crafting malicious realm documents and access to import functionality; likely requires some level of authentication or administrative access.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Refer to Red Hat advisories RHSA-2025:15336 through RHSA-2025:16399 for specific patched versions

Vendor Advisory: https://access.redhat.com/errata/RHSA-2025:15336

Restart Required: No

Instructions:

1. Review Red Hat advisories for your specific Keycloak/RH-SSO version. 2. Apply the appropriate security update via your package manager. 3. Verify the update was successful. 4. Test realm import functionality after patching.

🔧 Temporary Workarounds

Disable realm imports

all

Temporarily disable KeycloakRealmImport functionality until patches can be applied

Restrict environment variable access

all

Limit environment variables that can be referenced during realm imports

🧯 If You Can't Patch

  • Implement strict input validation on all realm import documents
  • Restrict realm import functionality to trusted administrators only

🔍 How to Verify

Check if Vulnerable:

Check Keycloak version against affected versions in Red Hat advisories; review if realm import functionality is enabled

Check Version:

keycloak/bin/kc.sh --version or check Keycloak admin console version information

Verify Fix Applied:

Verify Keycloak version is updated to patched version specified in Red Hat advisories

📡 Detection & Monitoring

Log Indicators:

  • Unusual realm import activity
  • Errors in realm import processing
  • Suspicious environment variable references in import logs

Network Indicators:

  • Unusual API calls to realm import endpoints
  • Large or complex realm import requests

SIEM Query:

source="keycloak" AND ("realm import" OR "KeycloakRealmImport") AND (error OR exception OR suspicious)

🔗 References

📤 Share & Export