CVE-2023-6291
📋 TL;DR
This vulnerability in Keycloak's redirect_uri validation logic allows attackers to bypass host restrictions and steal access tokens. Attackers can then impersonate legitimate users. All Keycloak deployments using affected versions are vulnerable.
💻 Affected Systems
- Keycloak
📦 What is this software?
Keycloak by Redhat
Migration Toolkit For Applications by Redhat
View all CVEs affecting Migration Toolkit For Applications →
Migration Toolkit For Applications by Redhat
View all CVEs affecting Migration Toolkit For Applications →
Openshift Container Platform For Ibm Z by Redhat
View all CVEs affecting Openshift Container Platform For Ibm Z →
Openshift Container Platform For Ibm Z by Redhat
View all CVEs affecting Openshift Container Platform For Ibm Z →
Openshift Container Platform For Linuxone by Redhat
View all CVEs affecting Openshift Container Platform For Linuxone →
Openshift Container Platform For Linuxone by Redhat
View all CVEs affecting Openshift Container Platform For Linuxone →
Openshift Container Platform For Power by Redhat
View all CVEs affecting Openshift Container Platform For Power →
⚠️ Risk & Real-World Impact
Worst Case
Complete account takeover and privilege escalation across all integrated applications using stolen access tokens.
Likely Case
Targeted account compromise leading to unauthorized access to sensitive data in connected applications.
If Mitigated
Limited impact if strong additional authentication factors and token validation are implemented.
🎯 Exploit Status
Requires attacker to craft malicious redirect_uri and trick user into authentication flow. No public exploit code known at this time.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Keycloak 22.0.5, 21.1.6, 20.0.7 or later
Vendor Advisory: https://access.redhat.com/errata/RHSA-2023:7854
Restart Required: Yes
Instructions:
1. Backup your Keycloak configuration and database. 2. Download patched version from official Keycloak website. 3. Stop Keycloak service. 4. Replace with patched version. 5. Restart Keycloak service. 6. Verify functionality.
🔧 Temporary Workarounds
Temporary redirect_uri restriction
allTighten redirect_uri validation rules to only allow specific, trusted domains
Update Keycloak realm settings to restrict valid redirect URIs to exact matches only
🧯 If You Can't Patch
- Implement network segmentation to isolate Keycloak from untrusted networks
- Enable additional authentication factors (MFA) for all users to reduce impact of token theft
🔍 How to Verify
Check if Vulnerable:
Check Keycloak version via admin console or by examining server logs for version information
Check Version:
Check Keycloak server startup logs or use: java -jar keycloak.jar --version
Verify Fix Applied:
Verify version is 22.0.5, 21.1.6, 20.0.7 or later and test redirect_uri validation with known malicious patterns
📡 Detection & Monitoring
Log Indicators:
- Unusual redirect_uri patterns in authentication logs
- Multiple failed authentication attempts with varying redirect parameters
Network Indicators:
- Unexpected redirects to non-whitelisted domains during OAuth flows
SIEM Query:
source="keycloak" AND (event="AUTHENTICATION" OR event="OAUTH") AND redirect_uri NOT IN ["allowed_domains_list"]
🔗 References
- https://access.redhat.com/errata/RHSA-2023:7854
- https://access.redhat.com/errata/RHSA-2023:7855
- https://access.redhat.com/errata/RHSA-2023:7856
- https://access.redhat.com/errata/RHSA-2023:7857
- https://access.redhat.com/errata/RHSA-2023:7858
- https://access.redhat.com/errata/RHSA-2023:7860
- https://access.redhat.com/errata/RHSA-2023:7861
- https://access.redhat.com/errata/RHSA-2024:0798
- https://access.redhat.com/errata/RHSA-2024:0799
- https://access.redhat.com/errata/RHSA-2024:0800
- https://access.redhat.com/errata/RHSA-2024:0801
- https://access.redhat.com/errata/RHSA-2024:0804
- https://access.redhat.com/security/cve/CVE-2023-6291
- https://bugzilla.redhat.com/show_bug.cgi?id=2251407
- https://access.redhat.com/errata/RHSA-2023:7854
- https://access.redhat.com/errata/RHSA-2023:7855
- https://access.redhat.com/errata/RHSA-2023:7856
- https://access.redhat.com/errata/RHSA-2023:7857
- https://access.redhat.com/errata/RHSA-2023:7858
- https://access.redhat.com/errata/RHSA-2023:7860
- https://access.redhat.com/errata/RHSA-2023:7861
- https://access.redhat.com/errata/RHSA-2024:0798
- https://access.redhat.com/errata/RHSA-2024:0799
- https://access.redhat.com/errata/RHSA-2024:0800
- https://access.redhat.com/errata/RHSA-2024:0801
- https://access.redhat.com/errata/RHSA-2024:0804
- https://access.redhat.com/security/cve/CVE-2023-6291
- https://bugzilla.redhat.com/show_bug.cgi?id=2251407