New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LGTM.com - Java UnsafeTlsVersion false positive #4059
Comments
|
CC: @artem-smotrakov |
There are also:
And Apache's HttpClient class |
|
In our case at Gradle, you can see that we're actually using one of those builder.setSSLSocketFactory(new SSLConnectionSocketFactory(sslContextFactory.createSslContext(), SSL_PROTOCOLS, null, hostnameVerifier));Our SSL_PPROTOCOLS list is actually vulnerable here in this case. private static final String[] SSL_PROTOCOLS;
private static final String HTTPS_PROTOCOLS = "https.protocols";
static {
String httpsProtocols = System.getProperty(HTTPS_PROTOCOLS);
if (httpsProtocols != null) {
SSL_PROTOCOLS = httpsProtocols.split(",");
} else if (JavaVersion.current().isJava7() || (JavaVersion.current().isJava8() && Jvm.current().isIbmJvm())) {
SSL_PROTOCOLS = new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"};
} else {
SSL_PROTOCOLS = null;
}
}By default, we fall back to using Unfortunately, this true vulnerability (at least I think it is) is not captured. |


Description of the false positive
I'm running the beta of the CodeQL GitHub actions driven code-scanning feature. Since the
gradle/gradlerepo hasn't been built recently on LGTM.com, unfortunately, I can't link directly to it at the moment.https://github.com/gradle/gradle/blob/1e9444f521ab3bbec1a5b852c1e0c4e12fb81819/subprojects/resources-http/src/main/java/org/gradle/internal/resource/transport/http/DefaultSslContextFactory.java#L122-L122
The false positive here is from this logic:
This is the query flagging this issue.
codeql/java/ql/src/experimental/Security/CWE/CWE-327/UnsafeTlsVersion.ql
Lines 1 to 20 in 66541f2
@big-guy, and I spent some time investigating this query result earlier today and we believe but are not confident that this is a false positive.
Using the following sample code:
All test are run with JDK 11.
Run with
TLSyou get the following output:Run with
TLSv1.3you get the following output:Run with
TLSv1.2you get the following output:Unfortunately, it seems like
SSLContext.getInstance("...")doesn't seem to set a minimum-supported TLS version (as you might expect), but instead seems to be an upper-bound for supported version.It seems like the vulnerability here actually exists when you pick
SSLContext.getInstance("[ANYTHING]")but fail to restrict the TLS supported versions usingSSLSocket#setEnabledProtocols.Our understanding could be wrong here. I'd love if someone who has a better understanding of the Java TLS stack and TLS downgrade attacks could jump in here.
The text was updated successfully, but these errors were encountered: