@@ -37,29 +37,23 @@ class ProtocolVersion extends string {
37
37
or
38
38
this = "TLSv1_3" and result = 32
39
39
}
40
-
41
- /** Gets the protocol family for this protocol version. */
42
- ProtocolFamily getFamily ( ) {
43
- result = "SSLv23" and this in [ "SSLv2" , "SSLv3" ]
44
- or
45
- result = "TLS" and this in [ "TLSv1" , "TLSv1_1" , "TLSv1_2" , "TLSv1_3" ]
46
- }
47
- }
48
-
49
- /** An unspecific protocol version */
50
- class ProtocolFamily extends string {
51
- ProtocolFamily ( ) { this in [ "SSLv23" , "TLS" ] }
52
-
53
- /** Gets the bit mask for this protocol family. */
54
- int getBits ( ) {
55
- result = sum ( ProtocolVersion version | version .getFamily ( ) = this | version .getBit ( ) )
56
- }
57
40
}
58
41
59
42
/** The creation of a context. */
60
43
abstract class ContextCreation extends DataFlow:: Node {
61
- /** Gets the protocol version or family for this context. */
62
- abstract string getProtocol ( ) ;
44
+ /**
45
+ * Gets the protocol version for this context.
46
+ * There can be multiple values if the context was created
47
+ * using a non-specific version such as `TLS`.
48
+ */
49
+ abstract ProtocolVersion getProtocol ( ) ;
50
+
51
+ /**
52
+ * Holds if the context was created with a specific version
53
+ * rather than with a version flexible method, see:
54
+ * https://www.openssl.org/docs/manmaster/man3/DTLS_server_method.html#NOTES
55
+ */
56
+ predicate specificVersion ( ) { count ( this .getProtocol ( ) ) = 1 }
63
57
}
64
58
65
59
/** The creation of a connection from a context. */
@@ -91,13 +85,12 @@ abstract class ProtocolUnrestriction extends DataFlow::Node {
91
85
* This also serves as unrestricting these protocols.
92
86
*/
93
87
abstract class UnspecificContextCreation extends ContextCreation {
94
- // override ProtocolVersion getUnrestriction() {
95
- // // There is only one family, the two names are aliases in OpenSSL.
96
- // // see https://github.com/openssl/openssl/blob/13888e797c5a3193e91d71e5f5a196a2d68d266f/include/openssl/ssl.h.in#L1953-L1955
97
- // family in ["SSLv23", "TLS"] and
98
- // // see https://docs.python.org/3/library/ssl.html#ssl-contexts
99
- // result in ["SSLv2", "SSLv3", "TLSv1", "TLSv1_1", "TLSv1_2", "TLSv1_3"]
100
- // }
88
+ override ProtocolVersion getProtocol ( ) {
89
+ // There is only one family, the two names are aliases in OpenSSL.
90
+ // see https://github.com/openssl/openssl/blob/13888e797c5a3193e91d71e5f5a196a2d68d266f/include/openssl/ssl.h.in#L1953-L1955
91
+ // see https://docs.python.org/3/library/ssl.html#ssl-contexts
92
+ result in [ "SSLv2" , "SSLv3" , "TLSv1" , "TLSv1_1" , "TLSv1_2" , "TLSv1_3" ]
93
+ }
101
94
}
102
95
103
96
/** A model of a SSL/TLS library. */
@@ -108,8 +101,8 @@ abstract class TlsLibrary extends string {
108
101
/** Gets the name of a specific protocol version. */
109
102
abstract string specific_version_name ( ProtocolVersion version ) ;
110
103
111
- /** Gets a name, which is a member of `version_constants`, that can be used to specify the protocol family `family` . */
112
- abstract string unspecific_version_name ( ProtocolFamily family ) ;
104
+ /** Gets a name, which is a member of `version_constants`, that can be used to specify the entire protocol family. */
105
+ abstract string unspecific_version_name ( ) ;
113
106
114
107
/** Gets an API node representing the module or class holding the version constants. */
115
108
abstract API:: Node version_constants ( ) ;
@@ -119,9 +112,9 @@ abstract class TlsLibrary extends string {
119
112
result = this .version_constants ( ) .getMember ( this .specific_version_name ( version ) )
120
113
}
121
114
122
- /** Gets an API node representing the protocol family ` family` . */
123
- API:: Node unspecific_version ( ProtocolFamily family ) {
124
- result = this .version_constants ( ) .getMember ( this .unspecific_version_name ( family ) )
115
+ /** Gets an API node representing the protocol entire family. */
116
+ API:: Node unspecific_version ( ) {
117
+ result = this .version_constants ( ) .getMember ( this .unspecific_version_name ( ) )
125
118
}
126
119
127
120
/** Gets a creation of a context with a default protocol. */
@@ -133,14 +126,15 @@ abstract class TlsLibrary extends string {
133
126
/** Gets a creation of a context with a specific protocol version, known to be insecure. */
134
127
ContextCreation insecure_context_creation ( ProtocolVersion version ) {
135
128
result in [ this .specific_context_creation ( ) , this .default_context_creation ( ) ] and
129
+ result .specificVersion ( ) and
136
130
result .getProtocol ( ) = version and
137
131
version .isInsecure ( )
138
132
}
139
133
140
134
/** Gets a context that was created using `family`, known to have insecure instances. */
141
- ContextCreation unspecific_context_creation ( ProtocolFamily family ) {
135
+ ContextCreation unspecific_context_creation ( ) {
142
136
result in [ this .specific_context_creation ( ) , this .default_context_creation ( ) ] and
143
- result .getProtocol ( ) = family
137
+ not result .specificVersion ( )
144
138
}
145
139
146
140
/** Gets a dataflow node representing a connection being created in an insecure manner, not from a context. */
0 commit comments