@@ -37,29 +37,23 @@ class ProtocolVersion extends string {
3737 or
3838 this = "TLSv1_3" and result = 32
3939 }
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- }
5740}
5841
5942/** The creation of a context. */
6043abstract 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 }
6357}
6458
6559/** The creation of a connection from a context. */
@@ -91,13 +85,12 @@ abstract class ProtocolUnrestriction extends DataFlow::Node {
9185 * This also serves as unrestricting these protocols.
9286 */
9387abstract 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+ }
10194}
10295
10396/** A model of a SSL/TLS library. */
@@ -108,8 +101,8 @@ abstract class TlsLibrary extends string {
108101 /** Gets the name of a specific protocol version. */
109102 abstract string specific_version_name ( ProtocolVersion version ) ;
110103
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 ( ) ;
113106
114107 /** Gets an API node representing the module or class holding the version constants. */
115108 abstract API:: Node version_constants ( ) ;
@@ -119,9 +112,9 @@ abstract class TlsLibrary extends string {
119112 result = this .version_constants ( ) .getMember ( this .specific_version_name ( version ) )
120113 }
121114
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 ( ) )
125118 }
126119
127120 /** Gets a creation of a context with a default protocol. */
@@ -133,14 +126,15 @@ abstract class TlsLibrary extends string {
133126 /** Gets a creation of a context with a specific protocol version, known to be insecure. */
134127 ContextCreation insecure_context_creation ( ProtocolVersion version ) {
135128 result in [ this .specific_context_creation ( ) , this .default_context_creation ( ) ] and
129+ result .specificVersion ( ) and
136130 result .getProtocol ( ) = version and
137131 version .isInsecure ( )
138132 }
139133
140134 /** 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 ( ) {
142136 result in [ this .specific_context_creation ( ) , this .default_context_creation ( ) ] and
143- result .getProtocol ( ) = family
137+ not result .specificVersion ( )
144138 }
145139
146140 /** Gets a dataflow node representing a connection being created in an insecure manner, not from a context. */
0 commit comments