@@ -8,6 +8,7 @@ private import semmle.code.java.dataflow.DataFlow2
88
99/**
1010 * The creation of an object that prepares an SSL connection.
11+ *
1112 * This is a source for `SslEndpointIdentificationFlowConfig`.
1213 */
1314class SslConnectionInit extends DataFlow:: Node {
@@ -19,12 +20,15 @@ class SslConnectionInit extends DataFlow::Node {
1920
2021/**
2122 * A call to a method that establishes an SSL connection.
23+ *
2224 * This is a sink for `SslEndpointIdentificationFlowConfig`.
2325 */
2426class SslConnectionCreation extends DataFlow:: Node {
2527 SslConnectionCreation ( ) {
2628 exists ( MethodAccess ma , Method m |
27- m instanceof GetSslSessionMethod or
29+ m instanceof BeginHandshakeMethod or
30+ m instanceof SslWrapMethod or
31+ m instanceof SslUnwrapMethod or
2832 m instanceof SocketConnectMethod
2933 |
3034 ma .getMethod ( ) = m and
@@ -44,10 +48,16 @@ class SslConnectionCreation extends DataFlow::Node {
4448}
4549
4650/**
47- * An SSL object that was assigned a safe `SSLParameters` object and can be considered safe.
51+ * An SSL object that correctly verifies hostnames, or doesn't need to (because e.g. it's a server).
52+ *
4853 * This is a sanitizer for `SslEndpointIdentificationFlowConfig`.
4954 */
50- class SslConnectionWithSafeSslParameters extends DataFlow:: Node {
55+ abstract class SslUnsafeCertTrustSanitizer extends DataFlow:: Node { }
56+
57+ /**
58+ * An SSL object that was assigned a safe `SSLParameters` object and can be considered safe.
59+ */
60+ private class SslConnectionWithSafeSslParameters extends SslUnsafeCertTrustSanitizer {
5161 SslConnectionWithSafeSslParameters ( ) {
5262 exists ( SafeSslParametersFlowConfig config , DataFlow:: Node safe |
5363 config .hasFlowTo ( safe ) and
@@ -56,6 +66,21 @@ class SslConnectionWithSafeSslParameters extends DataFlow::Node {
5666 }
5767}
5868
69+ /**
70+ * An `SSLEngine` set in server mode.
71+ */
72+ private class SslEngineServerMode extends SslUnsafeCertTrustSanitizer {
73+ SslEngineServerMode ( ) {
74+ exists ( MethodAccess ma , Method m |
75+ m .hasName ( "setUseClientMode" ) and
76+ m .getDeclaringType ( ) .getASupertype * ( ) instanceof SSLEngine and
77+ ma .getMethod ( ) = m and
78+ ma .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getBooleanValue ( ) = false and
79+ this = DataFlow:: exprNode ( ma .getQualifier ( ) )
80+ )
81+ }
82+ }
83+
5984/**
6085 * Holds if the return value of `createSocket` is cast to `SSLSocket`
6186 * or the qualifier of `createSocket` is an instance of `SSLSocketFactory`.
0 commit comments