Skip to content

Commit 2c9d682

Browse files
author
edvraa
committed
comments
1 parent 74cb61a commit 2c9d682

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

csharp/ql/src/Security Features/CWE-614/RequireSSL.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import csharp
1717
import semmle.code.asp.WebConfig
1818
import semmle.code.csharp.frameworks.system.Web
1919

20+
// the query is a subset of `cs/web/cookie-secure-not-set` and
21+
// should be removed once it is promoted from experimental
2022
from XMLElement element
2123
where
2224
element instanceof FormsElement and

csharp/ql/src/experimental/Security Features/CWE-614/CookieWithoutSecure.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ where
6363
// the property wasn't explicitly set, so a default value from config is used
6464
not isPropertySet(oc, "Secure") and
6565
// the default in config is not set to `true`
66+
// the `exists` below covers the `cs/web/cookie-secure-not-set`
6667
not exists(XMLElement element |
6768
element instanceof FormsElement and
6869
element.(FormsElement).isRequireSSL()

csharp/ql/src/semmle/code/asp/WebConfig.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,40 @@ class FormsElement extends XMLElement {
7070
this = any(SystemWebXMLElement sw).getAChild("authentication").getAChild("forms")
7171
}
7272

73+
/**
74+
* Gets attribute's `requireSSL` value.
75+
*/
7376
string getRequireSSL() { result = getAttribute("requireSSL").getValue().trim().toLowerCase() }
7477

78+
/**
79+
* Holds if `requireSSL` value is true.
80+
*/
7581
predicate isRequireSSL() { getRequireSSL() = "true" }
7682
}
7783

7884
/** A `<httpCookies>` tag in an ASP.NET configuration file. */
7985
class HttpCookiesElement extends XMLElement {
8086
HttpCookiesElement() { this = any(SystemWebXMLElement sw).getAChild("httpCookies") }
8187

88+
/**
89+
* Gets attribute's `httpOnlyCookies` value.
90+
*/
8291
string getHttpOnlyCookies() {
8392
result = getAttribute("httpOnlyCookies").getValue().trim().toLowerCase()
8493
}
8594

8695
/**
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`.
8897
*/
8998
predicate isHttpOnlyCookies() { getHttpOnlyCookies() = "true" }
9099

100+
/**
101+
* Gets attribute's `requireSSL` value.
102+
*/
91103
string getRequireSSL() { result = getAttribute("requireSSL").getValue().trim().toLowerCase() }
92104

93105
/**
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.
95107
*/
96108
predicate isRequireSSL() {
97109
getRequireSSL() = "true"

csharp/ql/src/semmle/code/csharp/dataflow/flowsources/AuthCookie.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,16 @@ class OnAppendCookieHttpOnlyTrackingConfig extends OnAppendCookieTrackingConfig
141141
override string propertyName() { result = "HttpOnly" }
142142
}
143143

144+
/**
145+
* Tracks if a callback used in `OnAppendCookie` sets a cookie property to `true`.
146+
*/
144147
abstract class OnAppendCookieTrackingConfig extends DataFlow::Configuration {
145148
bindingset[this]
146149
OnAppendCookieTrackingConfig() { any() }
147150

151+
/**
152+
* Specifies the cookie property name to track.
153+
*/
148154
abstract string propertyName();
149155

150156
override predicate isSource(DataFlow::Node source) {

0 commit comments

Comments
 (0)