A cookie is set with httpOnly turned off, so scripts can read it

tx0/ts:cookie-without-http-onlyrecommendedwarningsecurity, cwe-1004

What it finds

A cookie without HttpOnly can be read by every script in the page, so a single cross-site scripting flaw is enough to steal it. Session cookies in particular are meant to be sent by the browser, not read by scripts.

Reported is the option httpOnly: false, as written for Express's res.cookie, for the cookie of express-session and for similar libraries.

From the rule's source, cookie_without_http_only.rs.

Example from the rule's tests
export const sessionOptions = { cookie: { httpOnly: false, secure: true } };tx0 reports: lets every script in the page readexport const fine = { cookie: { httpOnly: 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 from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:cookie-without-http-only" = "warning"

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/ts:cookie-without-http-only] reason="..."

tx0 explain tx0/ts:cookie-without-http-only shows the same in the terminal. Found a false positive? Report it.