@@ -8,6 +8,7 @@ private import semmle.code.java.dataflow.DataFlow2
8
8
9
9
/**
10
10
* The creation of an object that prepares an SSL connection.
11
+ *
11
12
* This is a source for `SslEndpointIdentificationFlowConfig`.
12
13
*/
13
14
class SslConnectionInit extends DataFlow:: Node {
@@ -19,12 +20,15 @@ class SslConnectionInit extends DataFlow::Node {
19
20
20
21
/**
21
22
* A call to a method that establishes an SSL connection.
23
+ *
22
24
* This is a sink for `SslEndpointIdentificationFlowConfig`.
23
25
*/
24
26
class SslConnectionCreation extends DataFlow:: Node {
25
27
SslConnectionCreation ( ) {
26
28
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
28
32
m instanceof SocketConnectMethod
29
33
|
30
34
ma .getMethod ( ) = m and
@@ -44,10 +48,16 @@ class SslConnectionCreation extends DataFlow::Node {
44
48
}
45
49
46
50
/**
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
+ *
48
53
* This is a sanitizer for `SslEndpointIdentificationFlowConfig`.
49
54
*/
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 {
51
61
SslConnectionWithSafeSslParameters ( ) {
52
62
exists ( SafeSslParametersFlowConfig config , DataFlow:: Node safe |
53
63
config .hasFlowTo ( safe ) and
@@ -56,6 +66,21 @@ class SslConnectionWithSafeSslParameters extends DataFlow::Node {
56
66
}
57
67
}
58
68
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
+
59
84
/**
60
85
* Holds if the return value of `createSocket` is cast to `SSLSocket`
61
86
* or the qualifier of `createSocket` is an instance of `SSLSocketFactory`.
0 commit comments