Skip to content

Commit 6fe2c2e

Browse files
runningcodeclaude
andauthored
fix(transport): Reject leaked eMudhra intermediate certificates (#6336)
* fix(transport): Reject leaked eMudhra intermediate certificates The private keys of eight eMudhra intermediates can be recovered from their certificates (CVE-2026-111943). Their Sectigo cross-signs chain to AAA Certificate Services, which is trusted on every Android version, so platform trust store updates won't reach every device. The envelope transport and the distribution client now reject servers that present one of these keys, right after the TLS handshake and before any request is written. Fixes JAVA-783 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog * ref(transport): Pass DistrustedCertificates to HttpConnection Inject the check through HttpConnection's constructor like AuthenticatorWrapper, so its tests can stub it instead of loading the real eMudhra certificate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(transport): Check distrusted eMudhra CAs on every TLS handshake Checking the server certificates once after connect() missed the new connections HttpURLConnection opens on its own to retry a request, and chains Android completes from intermediates cached on earlier connections. Wrap the SSLSocketFactory so every handshake is checked, and match the leaf's issuer by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog: Shorten the eMudhra entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog: Move the eMudhra entry to Unreleased Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8937206 commit 6fe2c2e

15 files changed

Lines changed: 888 additions & 13 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
- Keep UI profiling running when `startProfiler` is called before a requested stop takes effect at the end of the current chunk ([#6291](https://github.com/getsentry/sentry-java/pull/6291))
1919
- Before, the start call was ignored and the profiler still stopped at the end of the chunk, even in `TRACE` mode while sampled spans were active. On API 34 and lower, every later profile also stopped after one chunk.
20+
- Refuse to send data to servers whose certificate was issued by one of the leaked eMudhra intermediates (CVE-2026-111943) ([#6336](https://github.com/getsentry/sentry-java/pull/6336))
2021

2122
### Dependencies
2223

‎gradle/libs.versions.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "6.4.
290290
mockito-core = { module = "org.mockito:mockito-core", version = "5.24.0" }
291291
msgpack = { module = "org.msgpack:msgpack-core", version = "0.9.8" }
292292
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" }
293+
okhttp-tls = { module = "com.squareup.okhttp3:okhttp-tls", version.ref = "okhttp" }
293294
# apollo-runtime 5.x pulls in okhttp 5.x; mockwebserver 4.x is incompatible with that classpath
294295
okhttp-mockwebserver5 = { module = "com.squareup.okhttp3:mockwebserver", version = "5.3.0" }
295296
okio = { module = "com.squareup.okio:okio", version = "1.13.0" }

‎sentry-android-distribution/src/main/java/io/sentry/android/distribution/DistributionHttpClient.kt‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.sentry.android.distribution
22

33
import io.sentry.SentryLevel
44
import io.sentry.SentryOptions
5+
import io.sentry.transport.DistrustedCertificates
56
import java.io.BufferedReader
67
import java.io.IOException
78
import java.io.InputStreamReader
@@ -89,8 +90,9 @@ internal class DistributionHttpClient(private val options: SentryOptions) {
8990
connection.connectTimeout = options.connectionTimeoutMillis
9091
connection.readTimeout = options.readTimeoutMillis
9192

92-
if (connection is HttpsURLConnection && options.sslSocketFactory != null) {
93-
connection.sslSocketFactory = options.sslSocketFactory
93+
if (connection is HttpsURLConnection) {
94+
connection.sslSocketFactory =
95+
DistrustedCertificates.wrap(options.sslSocketFactory ?: connection.sslSocketFactory)
9496
}
9597

9698
val responseCode = connection.responseCode

‎sentry/api/sentry.api‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7777,6 +7777,10 @@ public final class io/sentry/transport/CurrentDateProvider : io/sentry/transport
77777777
public static fun getInstance ()Lio/sentry/transport/ICurrentDateProvider;
77787778
}
77797779

7780+
public final class io/sentry/transport/DistrustedCertificates {
7781+
public static fun wrap (Ljavax/net/ssl/SSLSocketFactory;)Ljavax/net/ssl/SSLSocketFactory;
7782+
}
7783+
77807784
public abstract interface class io/sentry/transport/ICurrentDateProvider {
77817785
public abstract fun getCurrentTimeMillis ()J
77827786
}

‎sentry/build.gradle.kts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ dependencies {
3131
testImplementation(libs.mockito.kotlin)
3232
testImplementation(libs.mockito.core)
3333
testImplementation(libs.msgpack)
34+
testImplementation(libs.okhttp.mockwebserver)
35+
testImplementation(libs.okhttp.tls)
3436
testImplementation(libs.okio)
3537
testImplementation(projects.sentryTestSupport)
3638
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package io.sentry.transport;
2+
3+
import java.security.cert.Certificate;
4+
import java.security.cert.X509Certificate;
5+
import java.util.Arrays;
6+
import java.util.HashSet;
7+
import java.util.Set;
8+
import javax.net.ssl.SSLPeerUnverifiedException;
9+
import javax.net.ssl.SSLSocketFactory;
10+
import javax.security.auth.x500.X500Principal;
11+
import org.jetbrains.annotations.ApiStatus;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
/**
15+
* Rejects servers whose certificate was issued by a CA that is known to be compromised but still
16+
* trusted by platform trust stores.
17+
*
18+
* <p>Browsers block such certificates on their own and require Certificate Transparency, but {@link
19+
* javax.net.ssl.HttpsURLConnection} does neither. Android only updates its CA store with OS updates
20+
* (or Mainline on Android 14+) and the JVM only with JDK updates, so a distrust by the root
21+
* programs doesn't reach every device.
22+
*/
23+
@ApiStatus.Internal
24+
public final class DistrustedCertificates {
25+
26+
/**
27+
* The eight eMudhra intermediates whose private keys can be recovered from their certificates
28+
* (CVE-2026-111943). Each key is in two certificates with the same subject: one issued by eMudhra
29+
* and a cross-sign by Sectigo's AAA Certificate Services root, which is trusted on every Android
30+
* version.
31+
*
32+
* <p>They are matched by name rather than by key because the server doesn't have to send them:
33+
* Android caches intermediates from earlier connections and completes a chain that is missing
34+
* one. The server always sends the leaf, which names its issuer, and since none of these CAs may
35+
* issue further CAs ({@code pathlen:0}), any certificate they issued is a leaf.
36+
*
37+
* @see <a
38+
* href="https://groups.google.com/a/mozilla.org/g/dev-security-policy/c/0R3XLJL6FuE">Compromised
39+
* eMudhra Intermediate Certificates</a>
40+
*/
41+
private static final Set<X500Principal> DISTRUSTED_CAS =
42+
new HashSet<>(
43+
Arrays.asList(
44+
new X500Principal("CN=EM DV TLS CA - G3B, O=eMudhra BV, C=NL"),
45+
new X500Principal("CN=EM EV TLS CA - G3B, O=eMudhra BV, C=NL"),
46+
new X500Principal("CN=EM OV TLS CA - G3B, O=eMudhra BV, C=NL"),
47+
new X500Principal("CN=EM OV CS CA - G3B, O=eMudhra BV, C=NL"),
48+
new X500Principal("CN=EM DV TLS CA - G3C, O=eMudhra Inc, C=US"),
49+
new X500Principal("CN=EM EV TLS CA - G3C, O=eMudhra Inc, C=US"),
50+
new X500Principal("CN=EM OV TLS CA - G3C, O=eMudhra Inc, C=US"),
51+
new X500Principal("CN=EM OV CS CA - G3C, O=eMudhra Inc, C=US")));
52+
53+
private DistrustedCertificates() {}
54+
55+
/**
56+
* Wraps {@code delegate} so that every TLS handshake of its sockets is checked, including the
57+
* ones {@link java.net.HttpURLConnection} makes on its own to retry a request on a new
58+
* connection.
59+
*/
60+
public static @NotNull SSLSocketFactory wrap(final @NotNull SSLSocketFactory delegate) {
61+
return new DistrustedCertificatesSocketFactory(delegate);
62+
}
63+
64+
/**
65+
* @param peerCertificates the certificates the server sent, leaf first
66+
*/
67+
static void check(final @NotNull Certificate[] peerCertificates)
68+
throws SSLPeerUnverifiedException {
69+
for (final Certificate certificate : peerCertificates) {
70+
if (certificate instanceof X509Certificate && isDistrusted((X509Certificate) certificate)) {
71+
throw new SSLPeerUnverifiedException(
72+
"The server's certificate chain contains a distrusted certificate.");
73+
}
74+
}
75+
}
76+
77+
private static boolean isDistrusted(final @NotNull X509Certificate certificate) {
78+
return DISTRUSTED_CAS.contains(certificate.getIssuerX500Principal())
79+
|| DISTRUSTED_CAS.contains(certificate.getSubjectX500Principal());
80+
}
81+
}

0 commit comments

Comments
 (0)