@@ -30,16 +30,22 @@ predicate cookieAppendSecureByDefault() {
3030 OnAppendCookieSecureTracking:: flowTo ( _)
3131}
3232
33- predicate insecureCookieOptionsCreation ( Expr sink ) {
33+ predicate secureFalseOrNotSet ( ObjectCreation oc ) {
34+ exists ( Assignment a |
35+ getAValueForProp ( oc , a , "Secure" ) = a .getRValue ( ) and
36+ a .getRValue ( ) .getValue ( ) = "false"
37+ )
38+ or
39+ not isPropertySet ( oc , "Secure" )
40+ }
41+
42+ predicate insecureCookieOptionsCreation ( ObjectCreation oc ) {
3443 // `Secure` property in `CookieOptions` passed to IResponseCookies.Append(...) wasn't set
35- exists ( ObjectCreation oc |
36- oc = sink and
37- oc .getType ( ) instanceof MicrosoftAspNetCoreHttpCookieOptions and
38- not isPropertySet ( oc , "Secure" ) and
39- exists ( DataFlow:: Node creation |
40- CookieOptionsTracking:: flow ( creation , _) and
41- creation .asExpr ( ) = oc
42- )
44+ oc .getType ( ) instanceof MicrosoftAspNetCoreHttpCookieOptions and
45+ secureFalseOrNotSet ( oc ) and
46+ exists ( DataFlow:: Node creation |
47+ CookieOptionsTracking:: flow ( creation , _) and
48+ creation .asExpr ( ) = oc
4349 )
4450}
4551
@@ -81,25 +87,24 @@ predicate insecureCookieCall(Call c) {
8187 insecureCookieCreationFromConfig ( c )
8288}
8389
84- predicate insecureCookieCreationAssignment ( Assignment a , Expr val ) {
85- exists ( ObjectCreation oc |
86- getAValueForProp ( oc , a , "Secure" ) = val and
87- val .getValue ( ) = "false" and
88- (
89- oc .getType ( ) instanceof SystemWebHttpCookie
90- or
91- oc .getType ( ) instanceof MicrosoftAspNetCoreHttpCookieOptions and
92- // there is no callback `OnAppendCookie` that sets `Secure` to true
93- not OnAppendCookieSecureTracking:: flowTo ( _) and
94- // the cookie option is passed to `Append`
95- exists ( DataFlow:: Node creation |
96- CookieOptionsTracking:: flow ( creation , _) and
97- creation .asExpr ( ) = oc
98- )
99- )
100- )
101- }
102-
90+ // predicate insecureCookieCreationAssignment(Assignment a, Expr val) {
91+ // exists(ObjectCreation oc |
92+ // getAValueForProp(oc, a, "Secure") = val and
93+ // val.getValue() = "false" and
94+ // (
95+ // oc.getType() instanceof SystemWebHttpCookie
96+ // or
97+ // oc.getType() instanceof MicrosoftAspNetCoreHttpCookieOptions and
98+ // // there is no callback `OnAppendCookie` that sets `Secure` to true
99+ // not OnAppendCookieSecureTracking::flowTo(_) and
100+ // // the cookie option is passed to `Append`
101+ // exists(DataFlow::Node creation |
102+ // CookieOptionsTracking::flow(creation, _) and
103+ // creation.asExpr() = oc
104+ // )
105+ // )
106+ // )
107+ // }
103108predicate insecureSecurePolicyAssignment ( Assignment a , Expr val ) {
104109 exists ( PropertyWrite pw |
105110 (
@@ -120,10 +125,6 @@ where
120125 or
121126 exists ( Assignment a |
122127 secureSink = a .getRValue ( ) and
123- (
124- insecureCookieCreationAssignment ( a , _)
125- or
126- insecureSecurePolicyAssignment ( a , _)
127- )
128+ insecureSecurePolicyAssignment ( a , _)
128129 )
129130select secureSink , "Cookie attribute 'Secure' is not set to true."
0 commit comments