Skip to content
Playground(another site)

bynk.http.cookie_domain_widens

Warning A cookie literal outside the __Host- prefix sets a domain, so every subdomain receives it (warning).

A cookie with no Domain attribute belongs to exactly the host that set it. Setting domain makes it available to that domain and every subdomain, so a sibling service, or a subdomain an attacker can take over, receives it and can set a cookie of the same name. That is rarely wanted, so it is a warning. Drop domain; or, if the cookie is a session cookie, name it __Host-…, which makes the compiler refuse a domain altogether (bynk.http.cookie_host_prefix). Keep domain only when subdomains genuinely share the login.

Example

Created("ok").withCookie(Cookie { name: "sid", value: "a", domain: Some("example.com") }) // ⚠ every subdomain receives it
Created("ok").withCookie(Cookie { name: "__Host-sid", value: "a" }) // ✓ this host only

In the Book

See also

  • The grammar rule it governs: http_handler.
  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.cookie_domain_widens shows the same from the installed toolchain, without a network.