11/**
22 * @name Sensitive cookies without the HttpOnly response header set
3- * @description Sensitive cookies without the 'HttpOnly' flag set leaves session cookies vulnerable to
3+ * @description A sensitive cookie without the 'HttpOnly' flag set may be vulnerable to
44 * an XSS attack.
55 * @kind path-problem
66 * @problem.severity warning
7- * @precision medium
7+ * @precision high
8+ * @security-severity 5.0
89 * @id java/sensitive-cookie-not-httponly
910 * @tags security
1011 * external/cwe/cwe-1004
@@ -101,8 +102,9 @@ predicate removesCookie(MethodCall ma) {
101102}
102103
103104/**
104- * A taint configuration tracking flow of a method that sets the `HttpOnly` flag,
105- * or one that removes a cookie, to a `ServletResponse.addCookie` call.
105+ * A taint configuration tracking the flow of a cookie that has had the
106+ * `HttpOnly` flag set, or has been removed, to a `ServletResponse.addCookie`
107+ * call.
106108 */
107109module SetHttpOnlyOrRemovesCookieToAddCookieConfig implements DataFlow:: ConfigSig {
108110 predicate isSource ( DataFlow:: Node source ) {
@@ -120,8 +122,8 @@ module SetHttpOnlyOrRemovesCookieToAddCookieFlow =
120122 TaintTracking:: Global< SetHttpOnlyOrRemovesCookieToAddCookieConfig > ;
121123
122124/**
123- * A cookie that is added to an HTTP response and which doesn't have `httpOnly ` set, used as a sink
124- * in `MissingHttpOnlyConfiguration `.
125+ * A cookie that is added to an HTTP response and which doesn't have `HttpOnly ` set, used as a sink
126+ * in `MissingHttpOnlyConfig `.
125127 */
126128class CookieResponseWithoutHttpOnlySink extends DataFlow:: ExprNode {
127129 CookieResponseWithoutHttpOnlySink ( ) {
@@ -157,9 +159,11 @@ predicate setsHttpOnlyInNewCookie(ClassInstanceExpr cie) {
157159
158160/**
159161 * A taint configuration tracking flow from a sensitive cookie without the `HttpOnly` flag
160- * set to its HTTP response.
162+ * set to an HTTP response.
163+ *
161164 * Tracks string literals containing sensitive names (`SensitiveCookieNameExpr`), to an `addCookie` call (as a `Cookie` object)
162165 * or an `addHeader` call (as a string) (`CookieResponseWithoutHttpOnlySink`).
166+ *
163167 * Passes through `Cookie` constructors and `toString` calls.
164168 */
165169module MissingHttpOnlyConfig implements DataFlow:: ConfigSig {
@@ -169,7 +173,7 @@ module MissingHttpOnlyConfig implements DataFlow::ConfigSig {
169173
170174 predicate isBarrier ( DataFlow:: Node node ) {
171175 // JAX-RS's `new NewCookie("session-access-key", accessKey, "/", null, null, 0, true, true)` and similar
172- // Cookie constructors, but barriers to considering the flow of the sensitive name, as httponly flag is set .
176+ // Cookie constructors that set the `HttpOnly` flag are considered barriers to the flow of sensitive names .
173177 setsHttpOnlyInNewCookie ( node .asExpr ( ) )
174178 }
175179
0 commit comments