A cookie is marked as not HttpOnly, so scripts in the page can read it

tx0/kotlin:cookie-readable-by-scriptsdefaultwarningsecurity/authn-authzdepth fastsecurity, cwe-1004

What it finds

Without HttpOnly, any script running in the page, injected ones included, can read the cookie through document.cookie. Session cookies in particular are kept from scripts.

From the rule's source, cookie_script_readable.rs.

Example from the rule's tests
fun session(id: String) {    val cookie = javax.servlet.http.Cookie("session", id)    cookie.setHttpOnly(false)tx0 reports: the cookie is set without HttpOnly    val other = Cookie("session", id, httpOnly = false)tx0 reports: the cookie is set without HttpOnly    cookie.isHttpOnly = true}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:cookie-readable-by-scripts" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:cookie-readable-by-scripts] reason="..."

tx0 explain tx0/kotlin:cookie-readable-by-scripts shows the same in the terminal. Found a false positive? Report it.