@@ -30,10 +30,16 @@ class SecureCookieConfiguration extends DataFlow::Configuration {
30
30
SecureCookieConfiguration ( ) { this = "SecureCookieConfiguration" }
31
31
32
32
override predicate isSource ( DataFlow:: Node source ) {
33
- exists ( Variable cookie , MethodAccess m |
34
- source .asExpr ( ) = cookie .getAnAccess ( ) and
35
- cookie .getAnAccess ( ) = m .getQualifier ( ) and
36
- m .getMethod ( ) .getName ( ) = "setSecure"
33
+ exists ( MethodAccess ma , Method m | ma .getMethod ( ) = m |
34
+ m .getDeclaringType ( ) instanceof TypeCookie and
35
+ m .getName ( ) = "setSecure" and
36
+ source .asExpr ( ) = ma .getQualifier ( ) and
37
+ forex ( DataFlow:: Node argSource |
38
+ DataFlow:: localFlow ( argSource , DataFlow:: exprNode ( ma .getArgument ( 0 ) ) ) and
39
+ not DataFlow:: localFlowStep ( _, argSource )
40
+ |
41
+ isSafeSecureCookieSetting ( argSource .asExpr ( ) )
42
+ )
37
43
)
38
44
}
39
45
@@ -43,18 +49,8 @@ class SecureCookieConfiguration extends DataFlow::Configuration {
43
49
}
44
50
}
45
51
46
- from MethodAccess add , SecureCookieConfiguration df
52
+ from MethodAccess add
47
53
where
48
54
add .getMethod ( ) instanceof ResponseAddCookieMethod and
49
- not exists ( Variable cookie , MethodAccess m |
50
- df .hasFlow ( DataFlow:: exprNode ( cookie .getAnAccess ( ) ) , DataFlow:: exprNode ( add .getArgument ( 0 ) ) ) and
51
- m .getMethod ( ) .getName ( ) = "setSecure" and
52
- forex ( DataFlow:: Node argSource |
53
- DataFlow:: localFlow ( argSource , DataFlow:: exprNode ( m .getArgument ( 0 ) ) ) and
54
- not DataFlow:: localFlowStep ( _, argSource )
55
- |
56
- isSafeSecureCookieSetting ( argSource .asExpr ( ) )
57
- ) and
58
- m .getQualifier ( ) = cookie .getAnAccess ( )
59
- )
55
+ not any ( SecureCookieConfiguration df ) .hasFlowToExpr ( add .getArgument ( 0 ) )
60
56
select add , "Cookie is added to response without the 'secure' flag being set."
0 commit comments