Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Trust-anchor handling and fallback paths still allow compromised certificate chains to bypass distrust checks.
3 open issues
What changed in this PR
Adds explicit distrust of compromised eMudhra intermediate CAs across Keycloak’s certificate validation and TLS clients, addressing #54197.
Changes:
- Adds certificate and public-key blocklists with trust-manager and certificate-path checks.
- Integrates distrust into clients, truststore merging, and the container’s JDK.
- Adds regression tests, certificate fixtures, and documentation.
| File | Description |
|---|---|
| services/src/test/resources/distrusted-certificates/emudhra-intermediates.pem | Adds compromised intermediate and cross-sign fixtures. |
| services/src/test/resources/distrusted-certificates/emsign-ecc-root-ca-g3.pem | Adds the unaffected root fixture. |
| services/src/test/resources/distrusted-certificates/dv-g3b-emudhra-chain.pem | Adds a compromised-chain fixture. |
| services/src/test/java/org/keycloak/truststore/DistrustedCertificatesTest.java | Tests distrust checks and truststore filtering. |
| services/src/main/java/org/keycloak/truststore/TruststoreBuilder.java | Excludes distrusted certificates during merging. |
| services/src/main/java/org/keycloak/truststore/JSSETruststoreConfigurator.java | Uses distrust-aware trust managers. |
| services/src/main/java/org/keycloak/truststore/DistrustedCertificates.java | Implements blocklists and validation wrappers. |
| services/src/main/java/org/keycloak/services/x509/NginxProxySslClientCertificateLookup.java | Adds distrust checks during chain reconstruction. |
| services/src/main/java/org/keycloak/connections/httpclient/HttpClientBuilder.java | Adds distrust-aware Apache HTTP client validation. |
| services/src/main/java/org/keycloak/authentication/authenticators/x509/CertificateValidator.java | Adds distrust checks during client-certificate revalidation. |
| quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/httpclient/VertxHttpClientFactory.java | Wraps configured Vert.x trust managers. |
| quarkus/container/Dockerfile | Extends the JDK certificate blocklist. |
| docs/guides/server/keycloak-truststore.adoc | Documents distrust behavior and scope. |
Review effort: Balanced
The private keys of eight eMudhra intermediate CAs were compromised (https://emudhra.we-have-a-problem.com/). They chain to emSign ECC Root CA - G3 and AAA Certificate Services, which are still in the JDK and OS truststores, and revocation is not checked for outgoing TLS connections by default. Reject certificates with the compromised keys, including their Sectigo cross-signs, in the outgoing HTTP clients, the SMTP and LDAP socket factory, the X.509 client certificate path building and the merged truststore. Also add them to the JDK blocked.certs in the container image to cover the remaining TLS connections of the JVM. Closes keycloak#54197 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: tolik518 <function@returnnull.de>
6e092e9 to
a44150f
Compare
Reject chains with a certificate whose issuer is one of the compromised CAs and whose signature verifies with its key. This covers chains where the compromised intermediate is not presented: it is a trust anchor, it is fetched from the AIA extension, or the nginx and RFC 9440 lookups only have the leaf. The JDK blocked.certs list in the container image only matches fingerprints, so also add the copies of the ECDSA-signed certificates with the signature value s replaced by n - s. Closes keycloak#54197 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: tolik518 <function@returnnull.de>8000
There was a problem hiding this comment.
@tolik518 Thank you for the PR. I appreciate the impact of the compromised CA. However, I disagree Keycloak should manage on its own the untrusted certs – the trusted certs are fully in control of the admin with the fallback to OS/JDK certs.
We should instead consider introducing a supported option for providing CRL file to the truststores, and/or enabling CRL-DP.
WDYT @keycloak/cloud-native?
I think such an option alone has little value. Only problem it solves is that it can revoke some certs from the default java truststore. You can do the same today by specifying truststore path and declare trust anchors explicitly. Personally I don't find it easier to have CRL than truststore and the latter is arguably safer as it is explicit. CRLs/CRL-DP only makes sense when you have truststore reload ( #52520 ), or am I missing some scenario? |
|
Maybe if you tend to trust wide range of certificates, once-read CRL makes sense as you revoke only one issued cert, I'd still go with own truststore path instead of relying on JDK/OS truststores. |
|
Just to be clear, I think CRL as feature makes sense, I was just referring in relation to what this PR is trying to solve. |
|
IMHO, CRL would make sense exactly in the scenario this PR is trying to solve: you want to keep leveraging the default OS/JDK truststore but you need an escape hatch to temporarily exclude a single cert (before the default truststore is updated) to avoid (re-)building your own for whatever reason. |
|
As you wish. |
|
I just came across this website, which suggested adding the SHA-256 fingerprints of the compromised certs into |
|
@rtau-cca Yes, that's actually suggested by OpenJDK. |
|
I'm going to close this PR as that's not an approach we want to take. @tolik518 Feel free to open an RFE for supporting CRL and/or CRL-DP. Thanks. |

Closes #54197
Rejects certificates for the eight compromised eMudhra intermediate CAs, including their Sectigo cross-signs. They chain to roots still in the JDK/OS truststores (emSign ECC Root CA - G3 in the UBI image), and outgoing TLS doesn't check revocation by default.
DistrustedCertificates: matches by SPKI SHA-256 and certificate fingerprint.TruststoreBuilderskips these certificates if they appear in the truststore paths.blocked.certs, which covers the rest of the JVM (e.g. inbound mTLS falling back to the system truststore).Tests:
DistrustedCertificatesTest. Also checked with a local TLS server (a chain containing the compromised intermediate is rejected byHttpClientBuilderand the SMTP/LDAP socket factory) and against the official image.This PR was prepared with an AI agent (Claude Code); I reviewed and verified the changes.