@@ -1251,19 +1251,16 @@ module Http {
1251
1251
* Holds if the `Secure` flag of the cookie is known to have a value of `b`.
1252
1252
*/
1253
1253
predicate hasSecureFlag ( boolean b ) {
1254
- exists ( this .getHeaderArg ( ) ) and
1255
- (
1256
- exists ( StringLiteral sl |
1257
- sl .getText ( ) .regexpMatch ( "(?i).*;\\s*secure(;.*|\\s*)" ) and
1258
- TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1259
- b = true
1260
- )
1254
+ exists ( StringLiteral sl |
1255
+ // `sl` is likely a substring of the header
1256
+ TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1257
+ sl .getText ( ) .regexpMatch ( "(?i).*;\\s*secure(;.*|\\s*)" ) and
1258
+ b = true
1261
1259
or
1262
- exists ( StringLiteral sl |
1263
- not sl .getText ( ) .regexpMatch ( "(?i).*;\\s*secure(;.*|\\s*)" ) and
1264
- DataFlow:: localFlow ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1265
- b = false
1266
- )
1260
+ // `sl` is the entire header
1261
+ DataFlow:: localFlow ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1262
+ not sl .getText ( ) .regexpMatch ( "(?i).*;\\s*secure(;.*|\\s*)" ) and
1263
+ b = false
1267
1264
)
1268
1265
}
1269
1266
@@ -1291,31 +1288,24 @@ module Http {
1291
1288
* Holds if the `SameSite` flag of the cookie is known to have a value of `v`.
1292
1289
*/
1293
1290
predicate hasSameSiteAttribute ( SameSiteValue v ) {
1294
- exists ( this .getHeaderArg ( ) ) and
1295
- (
1296
- exists ( StringLiteral sl |
1291
+ exists ( StringLiteral sl |
1292
+ // `sl` is likely a substring of the header
1293
+ TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1294
+ (
1297
1295
sl .getText ( ) .regexpMatch ( "(?i).*;\\s*samesite=strict(;.*|\\s*)" ) and
1298
- TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1299
1296
v instanceof SameSiteStrict
1300
- )
1301
- or
1302
- exists ( StringLiteral sl |
1297
+ or
1303
1298
sl .getText ( ) .regexpMatch ( "(?i).*;\\s*samesite=lax(;.*|\\s*)" ) and
1304
- TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1305
1299
v instanceof SameSiteLax
1306
- )
1307
- or
1308
- exists ( StringLiteral sl |
1300
+ or
1309
1301
sl .getText ( ) .regexpMatch ( "(?i).*;\\s*samesite=none(;.*|\\s*)" ) and
1310
- TaintTracking:: localTaint ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1311
1302
v instanceof SameSiteNone
1312
1303
)
1313
1304
or
1314
- exists ( StringLiteral sl |
1315
- not sl .getText ( ) .regexpMatch ( "(?i).*;\\s*samesite=(strict|lax|none)(;.*|\\s*)" ) and
1316
- DataFlow:: localFlow ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1317
- v instanceof SameSiteLax // Lax is the default
1318
- )
1305
+ // `sl` is the entire header
1306
+ DataFlow:: localFlow ( DataFlow:: exprNode ( sl ) , this .getHeaderArg ( ) ) and
1307
+ not sl .getText ( ) .regexpMatch ( "(?i).*;\\s*samesite=(strict|lax|none)(;.*|\\s*)" ) and
1308
+ v instanceof SameSiteLax // Lax is the default
1319
1309
)
1320
1310
}
1321
1311
}
0 commit comments