You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); //GOOD: Set a valid endpointIdentificationAlgorithm for SSL engine to trigger hostname verification
sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); //GOOD: Set a valid endpointIdentificationAlgorithm for SSL socket to trigger hostname verification
Copy file name to clipboardExpand all lines: java/ql/src/experimental/Security/CWE/CWE-273/UnsafeCertTrust.qhelp
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,9 @@
5
5
6
6
<overview>
7
7
<p>Java offers two mechanisms for SSL authentication - trust manager and hostname verifier. Trust manager validates the peer's certificate chain while hostname verification establishes that the hostname in the URL matches the hostname in the server's identification.</p>
8
-
<p>Unsafe implementation of the interface X509TrustManager and HostnameVerifier ignores all SSL certificate validation errors when establishing an HTTPS connection, thereby making the app vulnerable to man-in-the-middle attacks.</p>
9
-
<p>This query checks whether trust manager is set to trust all certificates or the hostname verifier is turned off.</p>
8
+
<p>And when SSLSocket or SSLEngine is created without a valid parameter of setEndpointIdentificationAlgorithm, hostname verification is disabled by default.</p>
9
+
<p>Unsafe implementation of the interface X509TrustManager, HostnameVerifier, and SSLSocket/SSLEngine ignores all SSL certificate validation errors when establishing an HTTPS connection, thereby making the app vulnerable to man-in-the-middle attacks.</p>
10
+
<p>This query checks whether trust manager is set to trust all certificates, the hostname verifier is turned off, or setEndpointIdentificationAlgorithm is missing. The query also covers a special implementation com.rabbitmq.client.ConnectionFactory.</p>
10
11
</overview>
11
12
12
13
<recommendation>
@@ -29,5 +30,17 @@ no validation is performed thus any certificate is trusted. In the 'GOOD' case,
<ahref="https://github.com/advisories/GHSA-xvch-r4wf-h8w9">CVE-2018-17187: Apache Qpid Proton-J transport issue with hostname verification</a>
35
+
</li>
36
+
<li>
37
+
<ahref="https://github.com/advisories/GHSA-46j3-r4pj-4835">CVE-2018-8034: Apache Tomcat - host name verification when using TLS with the WebSocket client</a>
38
+
</li>
39
+
<li>
40
+
<ahref="https://github.com/advisories/GHSA-w4g2-9hj6-5472">CVE-2018-11087: Pivotal Spring AMQP vulnerability due to lack of hostname validation</a>
41
+
</li>
42
+
<li>
43
+
<ahref="https://github.com/advisories/GHSA-m9w8-v359-9ffr">CVE-2018-11775: TLS hostname verification issue when using the Apache ActiveMQ Client</a>
Copy file name to clipboardExpand all lines: java/ql/src/experimental/Security/CWE/CWE-273/UnsafeCertTrust.ql
+139-6Lines changed: 139 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,14 @@
1
1
/**
2
2
* @id java/unsafe-cert-trust
3
-
* @name Unsafe implementation of trusting any certificate in SSL configuration
4
-
* @description Unsafe implementation of the interface X509TrustManagerand HostnameVerifier ignores all SSL certificate validation errors when establishing an HTTPS connection, thereby making the app vulnerable to man-in-the-middle attacks.
3
+
* @name Unsafe implementation of trusting any certificate or missing hostname verification in SSL configuration
4
+
* @description Unsafe implementation of the interface X509TrustManager, HostnameVerifier, and SSLSocket/SSLEngine ignores all SSL certificate validation errors when establishing an HTTPS connection, thereby making the app vulnerable to man-in-the-middle attacks.
5
5
* @kind problem
6
6
* @tags security
7
7
* external/cwe-273
8
8
*/
9
9
10
10
import java
11
11
import semmle.code.java.security.Encryption
12
-
import semmle.code.java.dataflow.DataFlow
13
-
import DataFlow
14
12
15
13
/**
16
14
* X509TrustManager class that blindly trusts all certificates in server SSL authentication
@@ -79,7 +77,7 @@ class TrustAllHostnameVerify extends MethodAccess {
ce.getControlFlowNode().getASuccessor().(VariableAssign).getDestVar()=ssl//With a type cast like SSLSocket socket = (SSLSocket) socketFactory.createSocket("www.example.com", 443);
hasEndpointIdentificationAlgorithm(newSsl)//Not set in its caller either
194
+
)
195
+
)and
196
+
notexists(MethodAccessma|ma.getMethod()instanceofHostnameVerifierVerify)//Reduce false positives since this method access set default hostname verifier
0 commit comments