A cookie is set without the secure and httponly flags
What it finds
setcookie('session', $id): a cookie without the secure flag is also sent over plain HTTP, and one without httponly can be read by scripts in the page, so an injected script can steal it. Both flags, as arguments or in the options array, protect it.
From the rule's source, cookie_without_protection.rs.
<?phpsetcookie('session', $id);tx0 reports: this cookie is set without both secure and httponlysetcookie('session', $id, ['secure' => true, 'httponly' => true, 'samesite' => 'Lax']);setcookie('session', $id, 0, '/', '', true, true);setcookie('theme', 'dark', ['expires' => 0]);tx0 reports: this cookie is set without both secure and httponly Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:cookie-without-protection" = "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/php:cookie-without-protection] reason="..."tx0 explain tx0/php:cookie-without-protection shows the same in the terminal. Found a false positive? Report it.