@@ -26,18 +26,31 @@ predicate isSafeSecureCookieSetting(Expr e) {
2626 )
2727}
2828
29+ class SecureCookieConfiguration extends DataFlow:: Configuration {
30+ SecureCookieConfiguration ( ) { this = "SecureCookieConfiguration" }
31+
32+ override predicate isSource ( DataFlow:: Node source ) {
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+ )
43+ )
44+ }
45+
46+ override predicate isSink ( DataFlow:: Node sink ) {
47+ sink .asExpr ( ) =
48+ any ( MethodAccess add | add .getMethod ( ) instanceof ResponseAddCookieMethod ) .getArgument ( 0 )
49+ }
50+ }
51+
2952from MethodAccess add
3053where
3154 add .getMethod ( ) instanceof ResponseAddCookieMethod and
32- not exists ( Variable cookie , MethodAccess m |
33- add .getArgument ( 0 ) = cookie .getAnAccess ( ) and
34- m .getMethod ( ) .getName ( ) = "setSecure" and
35- forex ( DataFlow:: Node argSource |
36- DataFlow:: localFlow ( argSource , DataFlow:: exprNode ( m .getArgument ( 0 ) ) ) and
37- not DataFlow:: localFlowStep ( _, argSource )
38- |
39- isSafeSecureCookieSetting ( argSource .asExpr ( ) )
40- ) and
41- m .getQualifier ( ) = cookie .getAnAccess ( )
42- )
55+ not any ( SecureCookieConfiguration df ) .hasFlowToExpr ( add .getArgument ( 0 ) )
4356select add , "Cookie is added to response without the 'secure' flag being set."
0 commit comments