@@ -30,10 +30,16 @@ class SecureCookieConfiguration extends DataFlow::Configuration {
3030 SecureCookieConfiguration ( ) { this = "SecureCookieConfiguration" }
3131
3232 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+ )
3743 )
3844 }
3945
@@ -43,18 +49,8 @@ class SecureCookieConfiguration extends DataFlow::Configuration {
4349 }
4450}
4551
46- from MethodAccess add , SecureCookieConfiguration df
52+ from MethodAccess add
4753where
4854 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 ) )
6056select add , "Cookie is added to response without the 'secure' flag being set."
0 commit comments