CVE-2022-4137
📋 TL;DR
This reflected cross-site scripting (XSS) vulnerability in Keycloak's 'oob' OAuth endpoint allows attackers to inject malicious scripts via crafted links, potentially compromising user details when victims interact with them. It affects Keycloak users and administrators who access malicious links, leading to unauthorized data collection or modification.
💻 Affected Systems
- Keycloak
📦 What is this software?
Keycloak by Redhat
⚠️ Risk & Real-World Impact
Worst Case
Attackers could steal sensitive user credentials, modify account details, or perform actions on behalf of users, leading to full account compromise and data breaches.
Likely Case
Attackers trick users into clicking malicious links to steal session tokens or personal information, resulting in account takeover or data theft.
If Mitigated
With proper input validation and patching, the risk is minimized to low, preventing script injection and maintaining security.
🎯 Exploit Status
Exploitation requires user interaction (clicking a link), making it dependent on social engineering but technically straightforward.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Refer to Red Hat advisories for specific patched versions (e.g., Keycloak updates in RHSA-2023:1043, RHSA-2023:1044, RHSA-2023:1045, RHSA-2023:1049)
Vendor Advisory: https://access.redhat.com/security/cve/CVE-2022-4137
Restart Required: Yes
Instructions:
1. Check current Keycloak version. 2. Apply the latest security patch from Red Hat or upstream Keycloak. 3. Restart the Keycloak service to apply changes. 4. Verify the fix by testing the 'oob' endpoint.
🔧 Temporary Workarounds
Disable 'oob' OAuth endpoint
allTemporarily disable the vulnerable 'oob' endpoint to prevent exploitation until patching is complete.
Modify Keycloak configuration to remove or disable the 'oob' endpoint; consult Keycloak documentation for specific steps.
🧯 If You Can't Patch
- Implement strict input validation and output encoding on the 'oob' endpoint to block malicious scripts.
- Use web application firewalls (WAFs) to filter and block requests containing suspicious patterns related to XSS.
🔍 How to Verify
Check if Vulnerable:
Test the 'oob' endpoint by attempting to inject a null-byte or script payload; if it reflects in error pages without sanitization, the system is vulnerable.
Check Version:
keycloak --version or check the Keycloak admin console for version information.
Verify Fix Applied:
After patching, retest the 'oob' endpoint to ensure injected scripts are properly sanitized or blocked, and check that the error page no longer includes arbitrary URIs.
📡 Detection & Monitoring
Log Indicators:
- Log entries showing unusual requests to the 'oob' endpoint with suspicious parameters or null-byte characters.
Network Indicators:
- HTTP requests containing crafted URIs or script tags targeting the 'oob' endpoint.
SIEM Query:
source="keycloak.log" AND (uri="*oob*" AND (param="*%00*" OR param="*<script>*"))
🔗 References
- https://access.redhat.com/errata/RHSA-2023:1043
- https://access.redhat.com/errata/RHSA-2023:1044
- https://access.redhat.com/errata/RHSA-2023:1045
- https://access.redhat.com/errata/RHSA-2023:1049
- https://access.redhat.com/security/cve/CVE-2022-4137
- https://bugzilla.redhat.com/show_bug.cgi?id=2148496
- https://access.redhat.com/errata/RHSA-2023:1043
- https://access.redhat.com/errata/RHSA-2023:1044
- https://access.redhat.com/errata/RHSA-2023:1045
- https://access.redhat.com/errata/RHSA-2023:1049
- https://access.redhat.com/security/cve/CVE-2022-4137
- https://bugzilla.redhat.com/show_bug.cgi?id=2148496