File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed
Security Features/CWE-614
experimental/Security Features/CWE-614
csharp/dataflow/flowsources Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ import csharp
17
17
import semmle.code.asp.WebConfig
18
18
import semmle.code.csharp.frameworks.system.Web
19
19
20
+ // the query is a subset of `cs/web/cookie-secure-not-set` and
21
+ // should be removed once it is promoted from experimental
20
22
from XMLElement element
21
23
where
22
24
element instanceof FormsElement and
Original file line number Diff line number Diff line change 63
63
// the property wasn't explicitly set, so a default value from config is used
64
64
not isPropertySet ( oc , "Secure" ) and
65
65
// the default in config is not set to `true`
66
+ // the `exists` below covers the `cs/web/cookie-secure-not-set`
66
67
not exists ( XMLElement element |
67
68
element instanceof FormsElement and
68
69
element .( FormsElement ) .isRequireSSL ( )
Original file line number Diff line number Diff line change @@ -70,28 +70,40 @@ class FormsElement extends XMLElement {
70
70
this = any ( SystemWebXMLElement sw ) .getAChild ( "authentication" ) .getAChild ( "forms" )
71
71
}
72
72
73
+ /**
74
+ * Gets attribute's `requireSSL` value.
75
+ */
73
76
string getRequireSSL ( ) { result = getAttribute ( "requireSSL" ) .getValue ( ) .trim ( ) .toLowerCase ( ) }
74
77
78
+ /**
79
+ * Holds if `requireSSL` value is true.
80
+ */
75
81
predicate isRequireSSL ( ) { getRequireSSL ( ) = "true" }
76
82
}
77
83
78
84
/** A `<httpCookies>` tag in an ASP.NET configuration file. */
79
85
class HttpCookiesElement extends XMLElement {
80
86
HttpCookiesElement ( ) { this = any ( SystemWebXMLElement sw ) .getAChild ( "httpCookies" ) }
81
87
88
+ /**
89
+ * Gets attribute's `httpOnlyCookies` value.
90
+ */
82
91
string getHttpOnlyCookies ( ) {
83
92
result = getAttribute ( "httpOnlyCookies" ) .getValue ( ) .trim ( ) .toLowerCase ( )
84
93
}
85
94
86
95
/**
87
- * Holds if there any chance that `httpOnlyCookies` is set to `true`.
96
+ * Holds if there is any chance that `httpOnlyCookies` is set to `true`.
88
97
*/
89
98
predicate isHttpOnlyCookies ( ) { getHttpOnlyCookies ( ) = "true" }
90
99
100
+ /**
101
+ * Gets attribute's `requireSSL` value.
102
+ */
91
103
string getRequireSSL ( ) { result = getAttribute ( "requireSSL" ) .getValue ( ) .trim ( ) .toLowerCase ( ) }
92
104
93
105
/**
94
- * Holds if there any chance that `requireSSL` is set to `true` either globally or for Forms.
106
+ * Holds if there is any chance that `requireSSL` is set to `true` either globally or for Forms.
95
107
*/
96
108
predicate isRequireSSL ( ) {
97
109
getRequireSSL ( ) = "true"
Original file line number Diff line number Diff line change @@ -141,10 +141,16 @@ class OnAppendCookieHttpOnlyTrackingConfig extends OnAppendCookieTrackingConfig
141
141
override string propertyName ( ) { result = "HttpOnly" }
142
142
}
143
143
144
+ /**
145
+ * Tracks if a callback used in `OnAppendCookie` sets a cookie property to `true`.
146
+ */
144
147
abstract class OnAppendCookieTrackingConfig extends DataFlow:: Configuration {
145
148
bindingset [ this ]
146
149
OnAppendCookieTrackingConfig ( ) { any ( ) }
147
150
151
+ /**
152
+ * Specifies the cookie property name to track.
153
+ */
148
154
abstract string propertyName ( ) ;
149
155
150
156
override predicate isSource ( DataFlow:: Node source ) {
You can’t perform that action at this time.
0 commit comments