CVE-2023-1664 Overview
A certificate validation bypass vulnerability was discovered in Red Hat Keycloak, an open-source identity and access management solution. This flaw occurs when the non-default "Revalidate Client Certificate" configuration option is enabled while the reverse proxy fails to properly validate certificates before passing them to Keycloak. When combined with a missing or misconfigured KC_SPI_TRUSTSTORE_FILE_FILE variable, an attacker can present arbitrary certificates that may be accepted by the server.
Critical Impact
Attackers can bypass client certificate validation in specific misconfigurations, potentially compromising the integrity and confidentiality of consumer applications relying on Keycloak for authentication.
Affected Products
- Red Hat Keycloak
- Red Hat Single Sign-On 7.0
- Red Hat Build of Quarkus
- Red Hat JBoss A-MQ 7
- Red Hat Migration Toolkit for Runtimes
Discovery Timeline
- 2023-05-26 - CVE-2023-1664 published to NVD
- 2025-01-15 - Last updated in NVD database
Technical Details for CVE-2023-1664
Vulnerability Analysis
This vulnerability represents an Improper Certificate Validation flaw (CWE-295) in Keycloak's client certificate handling mechanism. The issue manifests under a specific set of conditions: when the "Revalidate Client Certificate" option is enabled, and a reverse proxy upstream of Keycloak does not perform its own certificate validation. In this scenario, Keycloak becomes the sole point of certificate verification.
The core problem occurs when the KC_SPI_TRUSTSTORE_FILE_FILE environment variable is either missing or incorrectly configured. Without a properly configured truststore, Keycloak cannot validate the certificate chain, yet it may still accept connections. The system logs a warning message: "Cannot validate client certificate trust: Truststore not available" — however, this does not prevent the potentially unauthorized access.
While the attacker cannot directly access the Keycloak server itself through this vulnerability, the bypass of certificate validation can affect downstream consumer applications that trust Keycloak's authentication decisions, potentially compromising their integrity and confidentiality.
Root Cause
The root cause stems from improper error handling in Keycloak's certificate validation logic when the truststore is unavailable. Instead of failing closed (denying access when validation cannot be performed), the system fails open under certain configurations, allowing connections to proceed despite being unable to verify the client certificate's authenticity. This design flaw violates the principle of secure defaults and fail-safe behavior.
Attack Vector
The attack requires network access and targets the mutual TLS (mTLS) certificate validation process. An attacker can exploit this vulnerability by presenting a crafted or arbitrary client certificate when connecting to a Keycloak instance that meets the following conditions:
- The "Revalidate Client Certificate" option is enabled (non-default setting)
- The reverse proxy in front of Keycloak does not validate client certificates
- The KC_SPI_TRUSTSTORE_FILE_FILE variable is missing or misconfigured
When these conditions are met, the attacker's certificate may be accepted without proper chain-of-trust validation, allowing them to impersonate legitimate clients or gain unauthorized access to resources protected by certificate-based authentication.
Detection Methods for CVE-2023-1664
Indicators of Compromise
- Log entries containing "Cannot validate client certificate trust: Truststore not available" in Keycloak server logs
- Unexpected or unauthorized authentication events in access logs from untrusted certificate issuers
- Authentication requests with certificates not issued by your organization's certificate authority
- Anomalous login patterns from clients with unusual certificate metadata
Detection Strategies
- Monitor Keycloak logs for truststore-related warning messages indicating validation failures
- Implement alerting on authentication events where certificate validation was skipped or could not be completed
- Audit configuration settings periodically to ensure KC_SPI_TRUSTSTORE_FILE_FILE is properly set
- Deploy network monitoring to detect mTLS connections with unexpected certificate chains
Monitoring Recommendations
- Enable verbose logging for Keycloak's certificate validation subsystem during security audits
- Configure SIEM rules to flag any truststore-related error or warning messages
- Establish baseline metrics for certificate-based authentication patterns and alert on deviations
- Implement certificate transparency monitoring for any certificates claiming to represent your organization
How to Mitigate CVE-2023-1664
Immediate Actions Required
- Verify that the KC_SPI_TRUSTSTORE_FILE_FILE environment variable is properly configured and points to a valid truststore
- Ensure your reverse proxy (nginx, Apache, HAProxy) is configured to validate client certificates before forwarding requests to Keycloak
- Review and disable the "Revalidate Client Certificate" option if not explicitly required by your deployment architecture
- Audit recent authentication logs for any suspicious certificate-based access attempts
Patch Information
Red Hat has acknowledged this vulnerability. Refer to the Red Hat Bug Report #2182196 for official guidance, patch availability, and affected version details. Administrators should update to the latest patched versions of Keycloak and Red Hat Single Sign-On as they become available.
Workarounds
- Configure your reverse proxy to perform client certificate validation, ensuring Keycloak is not the sole validation point
- If the "Revalidate Client Certificate" feature is not required, disable it in the Keycloak configuration
- Implement strict truststore configuration validation during deployment to prevent misconfiguration
- Deploy network segmentation to limit exposure of Keycloak instances requiring mTLS authentication
# Verify truststore configuration
# Ensure KC_SPI_TRUSTSTORE_FILE_FILE environment variable is set correctly
echo $KC_SPI_TRUSTSTORE_FILE_FILE
# Verify the truststore file exists and is readable
ls -la $KC_SPI_TRUSTSTORE_FILE_FILE
# Check truststore contents using keytool
keytool -list -keystore $KC_SPI_TRUSTSTORE_FILE_FILE -storepass <your-password>
# Verify Keycloak can access the truststore (check logs for validation errors)
grep -i "truststore" /path/to/keycloak/logs/server.log
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


