Skip to content

Commit 26a24a3

Browse files
committed
prepare move to non-experimental
1 parent 44db920 commit 26a24a3

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

javascript/ql/lib/semmle/javascript/frameworks/CookieLibraries.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44

55
import javascript
66

7+
/**
8+
* Classes and predicates for reasoning about writes to cookies.
9+
*/
10+
module CookieWrites {
11+
/**
12+
* A write to a cookie.
13+
*/
14+
abstract class CookieWrite extends DataFlow::Node {
15+
/**
16+
* Holds if this cookie is secure, i.e. only transmitted over SSL.
17+
*/
18+
abstract predicate isSecure();
19+
20+
/**
21+
* Holds if this cookie is HttpOnly, i.e. not accessible by JavaScript.
22+
*/
23+
abstract predicate isHttpOnly();
24+
25+
/**
26+
* Holds if the cookie is likely an authentication cookie or otherwise sensitive.
27+
*/
28+
abstract predicate isSensitive();
29+
}
30+
}
31+
732
/**
833
* A model of the `js-cookie` library (https://github.com/js-cookie/js-cookie).
934
*/
@@ -26,6 +51,7 @@ private module JsCookie {
2651
}
2752

2853
class WriteAccess extends PersistentWriteAccess, DataFlow::CallNode {
54+
// TODO: CookieWrite
2955
WriteAccess() { this = libMemberCall("set") }
3056

3157
string getKey() { getArgument(0).mayHaveStringValue(result) }
@@ -54,6 +80,7 @@ private module BrowserCookies {
5480
}
5581

5682
class WriteAccess extends PersistentWriteAccess, DataFlow::CallNode {
83+
// TODO: CookieWrite
5784
WriteAccess() { this = libMemberCall("set") }
5885

5986
string getKey() { getArgument(0).mayHaveStringValue(result) }
@@ -82,6 +109,7 @@ private module LibCookie {
82109
}
83110

84111
class WriteAccess extends PersistentWriteAccess, DataFlow::CallNode {
112+
// TODO: CookieWrite
85113
WriteAccess() { this = libMemberCall("serialize") }
86114

87115
string getKey() { getArgument(0).mayHaveStringValue(result) }

javascript/ql/src/experimental/Security/CWE-1004/CookieWithoutHttpOnly.ql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
*/
1414

1515
import javascript
16-
import experimental.semmle.javascript.security.InsecureCookie::Cookie
16+
import experimental.semmle.javascript.security.InsecureCookie::Cookie as ExperimentalCookie
1717

18-
from CookieWrite cookie
19-
where cookie.isSensitive() and not cookie.isHttpOnly()
20-
select cookie, "Cookie attribute 'HttpOnly' is not set to true for this sensitive cookie."
18+
from DataFlow::Node node
19+
where
20+
exists(ExperimentalCookie::CookieWrite cookie | cookie = node |
21+
cookie.isSensitive() and not cookie.isHttpOnly()
22+
)
23+
or
24+
exists(CookieWrites::CookieWrite cookie | cookie = node |
25+
cookie.isSensitive() and not cookie.isHttpOnly()
26+
)
27+
select node, "Cookie attribute 'HttpOnly' is not set to true for this sensitive cookie."

javascript/ql/src/experimental/Security/CWE-614/InsecureCookie.ql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
*/
1212

1313
import javascript
14-
import experimental.semmle.javascript.security.InsecureCookie::Cookie
14+
import experimental.semmle.javascript.security.InsecureCookie::Cookie as ExperimentalCookie
1515

16-
from CookieWrite cookie
17-
where not cookie.isSecure()
18-
select cookie, "Cookie is added to response without the 'secure' flag being set to true"
16+
from DataFlow::Node node
17+
where
18+
exists(ExperimentalCookie::CookieWrite cookie | cookie = node | not cookie.isSecure())
19+
or
20+
exists(CookieWrites::CookieWrite cookie | cookie = node | not cookie.isSecure())
21+
select node, "Cookie is added to response without the 'secure' flag being set to true"

0 commit comments

Comments
 (0)