@@ -126,7 +126,9 @@ private module JsCookie {
126
126
127
127
override predicate isSecure ( ) {
128
128
// A cookie is secure if there are cookie options with the `secure` flag set to `true`.
129
- this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) .mayHaveBooleanValue ( true )
129
+ exists ( DataFlow:: Node value | value = this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) |
130
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
131
+ )
130
132
}
131
133
132
134
override predicate isSensitive ( ) { canHaveSensitiveCookie ( this .getArgument ( 0 ) ) }
@@ -162,7 +164,9 @@ private module BrowserCookies {
162
164
163
165
override predicate isSecure ( ) {
164
166
// A cookie is secure if there are cookie options with the `secure` flag set to `true`.
165
- this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) .mayHaveBooleanValue ( true )
167
+ exists ( DataFlow:: Node value | value = this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) |
168
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
169
+ )
166
170
or
167
171
// or, an explicit default has been set
168
172
exists ( DataFlow:: moduleMember ( "browser-cookies" , "defaults" ) .getAPropertyWrite ( "secure" ) )
@@ -201,7 +205,9 @@ private module LibCookie {
201
205
202
206
override predicate isSecure ( ) {
203
207
// A cookie is secure if there are cookie options with the `secure` flag set to `true`.
204
- this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) .mayHaveBooleanValue ( true )
208
+ exists ( DataFlow:: Node value | value = this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) |
209
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
210
+ )
205
211
}
206
212
207
213
override predicate isSensitive ( ) { canHaveSensitiveCookie ( this .getArgument ( 0 ) ) }
@@ -222,15 +228,19 @@ private module ExpressCookies {
222
228
override predicate isSecure ( ) {
223
229
// A cookie is secure if there are cookie options with the `secure` flag set to `true`.
224
230
// The default is `false`.
225
- this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) .mayHaveBooleanValue ( true )
231
+ exists ( DataFlow:: Node value | value = this .getOptionArgument ( 2 , CookieWrites:: secure ( ) ) |
232
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
233
+ )
226
234
}
227
235
228
236
override predicate isSensitive ( ) { canHaveSensitiveCookie ( this .getArgument ( 0 ) ) }
229
237
230
238
override predicate isHttpOnly ( ) {
231
239
// A cookie is httpOnly if there are cookie options with the `httpOnly` flag set to `true`.
232
240
// The default is `false`.
233
- this .getOptionArgument ( 2 , CookieWrites:: httpOnly ( ) ) .mayHaveBooleanValue ( true )
241
+ exists ( DataFlow:: Node value | value = this .getOptionArgument ( 2 , CookieWrites:: httpOnly ( ) ) |
242
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
243
+ )
234
244
}
235
245
}
236
246
@@ -272,9 +282,9 @@ private module ExpressCookies {
272
282
override predicate isSecure ( ) {
273
283
// The flag `secure` is not set by default (https://github.com/expressjs/session#Cookiesecure).
274
284
// The default value for cookie options is { path: '/', httpOnly: true, secure: false, maxAge: null }.
275
- // A cookie is secure if there are the cookie options with the ` secure` flag set to `true` or to `auto`.
276
- getCookieFlagValue ( CookieWrites :: secure ( ) ) .mayHaveBooleanValue ( true ) or
277
- getCookieFlagValue ( CookieWrites :: secure ( ) ) . mayHaveStringValue ( "auto" )
285
+ exists ( DataFlow :: Node value | value = getCookieFlagValue ( CookieWrites :: secure ( ) ) |
286
+ not value .mayHaveBooleanValue ( false ) // anything but `false` is accepted as being maybe true
287
+ )
278
288
}
279
289
280
290
override predicate isSensitive ( ) {
0 commit comments