@@ -45,37 +45,6 @@ predicate isInsecureTlsVersion(int val, string name, string fieldName) {
45
45
)
46
46
}
47
47
48
- /**
49
- * Holds of string literals or named constants matching `isLegacyFlagName`
50
- */
51
- predicate exprSuggestsOldVersion ( Expr node ) {
52
- isLegacyFlagName ( node .getStringValue ( ) ) or
53
- isLegacyFlagName ( node .( Name ) .getTarget ( ) .getName ( ) )
54
- }
55
-
56
- /**
57
- * Holds if `node` suggests an old TLS version according to `isLegacyFlagName`
58
- */
59
- predicate nodeSuggestsOldVersion ( AstNode node ) {
60
- // Map literal old: value or "old": value
61
- exprSuggestsOldVersion ( node .( KeyValueExpr ) .getKey ( ) )
62
- or
63
- // Variable initialisation old := value
64
- exists ( ValueSpec valueSpec , int childIdx | isLegacyFlagName ( valueSpec .getName ( childIdx ) ) |
65
- node = valueSpec .getInit ( childIdx )
66
- )
67
- or
68
- // Assignment old = value
69
- exists ( Assignment assignment , int childIdx |
70
- isLegacyFlagName ( assignment .getLhs ( childIdx ) .( Ident ) .getName ( ) )
71
- |
72
- node = assignment .getRhs ( childIdx )
73
- )
74
- or
75
- // Case clause 'case old:' or 'case "old":'
76
- exprSuggestsOldVersion ( node .( CaseClause ) .getAnExpr ( ) )
77
- }
78
-
79
48
/**
80
49
* Holds if `node` refers to a value returned alongside a non-nil error value.
81
50
*
@@ -163,9 +132,6 @@ DataFlow::Node nodeOrDeref(DataFlow::Node node) {
163
132
/**
164
133
* Holds if an insecure TLS version flows from `source` to `sink`, which is in turn written
165
134
* to a field of `base`. `message` describes the specific problem found.
166
- *
167
- * Contexts suggesting an intentionally insecure or legacy configuration are excluded (see
168
- * `nodeSuggestsOldVersion`), as are fields that may conditionally receive a modern TLS version.
169
135
*/
170
136
predicate isInsecureTlsVersionFlow (
171
137
DataFlow:: PathNode source , DataFlow:: PathNode sink , string message , DataFlow:: Node base
@@ -175,7 +141,6 @@ predicate isInsecureTlsVersionFlow(
175
141
cfg .isSource ( source .getNode ( ) , version ) and
176
142
cfg .isSink ( sink .getNode ( ) , fld , base , _) and
177
143
isInsecureTlsVersion ( version , _, fld .getName ( ) ) and
178
- not nodeSuggestsOldVersion ( base .asExpr ( ) .getParent * ( ) ) and
179
144
// Exclude cases where a secure TLS version can also flow to the same
180
145
// sink, or to different sinks that refer to the same base and field,
181
146
// which suggests a configurable security mode.
@@ -215,8 +180,7 @@ class TlsInsecureCipherSuitesFlowConfig extends TaintTracking::Configuration {
215
180
"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" , "TLS_ECDHE_RSA_WITH_RC4_128_SHA" ,
216
181
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" , "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" ]
217
182
|
218
- source = val .getARead ( ) and
219
- not nodeSuggestsOldVersion ( source .asExpr ( ) .getParent * ( ) )
183
+ source = val .getARead ( )
220
184
)
221
185
}
222
186
@@ -239,14 +203,12 @@ class TlsInsecureCipherSuitesFlowConfig extends TaintTracking::Configuration {
239
203
}
240
204
241
205
/**
242
- * Holds if `fieldWrite` writes `sink` to `base`.`fld`, and `fld` is `tls.Config.CipherSuites`,
243
- * and no parent of `base` is named suggesting an intentionally insecure configuration.
206
+ * Holds if `fieldWrite` writes `sink` to `base`.`fld`, and `fld` is `tls.Config.CipherSuites`.
244
207
*/
245
208
predicate isSink ( DataFlow:: Node sink , Field fld , DataFlow:: Node base , Write fieldWrite ) {
246
209
fld .hasQualifiedName ( "crypto/tls" , "Config" , "CipherSuites" ) and
247
210
fieldWrite = fld .getAWrite ( ) and
248
- fieldWrite .writesField ( base , fld , sink ) and
249
- not nodeSuggestsOldVersion ( base .asExpr ( ) .getParent * ( ) )
211
+ fieldWrite .writesField ( base , fld , sink )
250
212
}
251
213
252
214
override predicate isSink ( DataFlow:: Node sink ) { isSink ( sink , _, _, _) }
@@ -283,9 +245,11 @@ where
283
245
isInsecureTlsVersionFlow ( source , sink , message , _) or
284
246
isInsecureTlsCipherFlow ( source , sink , message )
285
247
) and
286
- // Exclude sinks guarded by a feature flag
287
- not getAFeatureFlagCheck ( ) .dominatesNode ( sink .getNode ( ) .asInstruction ( ) ) and
288
- not getALegacyVersionCheck ( ) .dominatesNode ( sink .getNode ( ) .asInstruction ( ) ) and
248
+ // Exclude sources or sinks guarded by a feature or legacy flag
249
+ not [ getAFeatureFlagCheck ( ) , getALegacyVersionCheck ( ) ]
250
+ .dominatesNode ( [ source , sink ] .getNode ( ) .asInstruction ( ) ) and
251
+ // Exclude sources or sinks that occur lexically within a block related to a feature or legacy flag
252
+ not astNodeIsFlag ( [ source , sink ] .getNode ( ) .asExpr ( ) .getParent * ( ) , [ featureFlag ( ) , legacyFlag ( ) ] ) and
289
253
// Exclude results in functions whose name documents insecurity
290
254
not exists ( FuncDef fn | fn = sink .getNode ( ) .asInstruction ( ) .getRoot ( ) |
291
255
isFeatureFlagName ( fn .getEnclosingFunction * ( ) .getName ( ) ) or
0 commit comments