A cookie policy sends cookies over plain HTTP or lets scripts read them
What it finds
CookieSecurePolicy.None lets cookies travel over unencrypted connections, where they can be read and replayed, and HttpOnlyPolicy.None lets scripts, including injected ones, read them. The policies of ASP.NET Core apply to every cookie of the app.
From the rule's source, weak_cookie_policy.rs.
using Microsoft.AspNetCore.Http; class Cookies{ void Set(CookieBuilder cookie) { cookie.SecurePolicy = CookieSecurePolicy.None;tx0 reports: CookieSecurePolicy.None weakens the protection of every cookie cookie.SecurePolicy = CookieSecurePolicy.Always; }} 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:weak-cookie-policy" = "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:weak-cookie-policy] reason="..."tx0 explain tx0/csharp:weak-cookie-policy shows the same in the terminal. Found a false positive? Report it.