A cookie is set to be sent without TLS or to be readable by scripts
What it finds
Secure = false lets the cookie travel over plain HTTP, where anyone on the way can read it; HttpOnly = false lets scripts on the page read it, so an injected script can steal a session. Both default to the safer value in current ASP.NET Core for authentication cookies; setting them to false turns that off.
From the rule's source, cookie_protection_off.rs.
using Microsoft.AspNetCore.Http; class Cookies{ void Set(HttpResponse response) { response.Cookies.Append("session", "v", new CookieOptions { Secure = false,tx0 reports: this cookie is sent over plain HTTP too HttpOnly = false,tx0 reports: this cookie can be read by scripts }); response.Cookies.Append("theme", "dark", new CookieOptions { Secure = true }); }} 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/csharp:cookie-protection-off" = "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/csharp:cookie-protection-off] reason="..."tx0 explain tx0/csharp:cookie-protection-off shows the same in the terminal. Found a false positive? Report it.