A cookie is set without the secure attribute
What it finds
A cookie without the Secure attribute is also sent over plain HTTP, where anyone on the network can read it, and a session cookie read that way lets them take over the session.
Reported are calls of a cookie method, as Express's res.cookie(name, value, options), whose options are an object literal without secure or with secure: false, and assignments of a literal to document.cookie that lack secure, unless they delete the cookie with max-age=0 or an expiry in 1970. Options spread from another object may set it and are left alone.
From the rule's source, cookie_without_secure.rs.
export function setCookies(res: { cookie(n: string, v: string, o?: object): void }, options: object) { res.cookie("session", "abc", { httpOnly: true });tx0 reports: do not set secure: true res.cookie("session", "abc", { secure: false });tx0 reports: secure: false lets the cookie travel res.cookie("session", "abc", { secure: true, httpOnly: true }); res.cookie("session", "abc", { ...options }); res.cookie("theme", "dark"); document.cookie = "theme=dark; path=/";tx0 reports: set without Secure document.cookie = "theme=dark; path=/; Secure";} 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:
[rules]
"tx0/ts:cookie-without-secure" = "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-secure] reason="..."tx0 explain tx0/ts:cookie-without-secure shows the same in the terminal. Found a false positive? Report it.