Skip to main content

How to fix: Cookie Domain Attribute Is Too Broad

A cookie is set with an explicit Domain= attribute that covers all subdomains (e.g., Domain=example.com or Domain=.example.com). This makes the cookie accessible from every subdomain, including potentially untrusted or third-party-hosted ones. Per RFC 6265bis, a leading dot is stripped and has no effect on browser behavior: both forms are equally subdomain-wide. Cookies that exist to be shared site-wide and authenticate nobody (analytics, consent state, locale and theme preferences) are not reported.

Why it matters

A subdomain that is vulnerable to XSS, or that is under attacker control via subdomain takeover, can read or overwrite cookies scoped to the parent domain. Session cookies shared across all subdomains are particularly high-risk.

An explicit Domain= attribute (with or without leading dot) causes the browser to send the cookie to all subdomains of the specified domain. Omitting Domain entirely makes the cookie host-only, which is the safer default per RFC 6265bis.

How to fix it

  1. 1Omit the Domain= attribute entirely to make the cookie host-only.
  2. 2If cross-subdomain sharing is required, explicitly enumerate the subdomains that need access and audit them for XSS.
  3. 3Use the __Host- prefix on session cookies to enforce host-only at the browser level.

Code examples

Host-only cookie (omit Domain)

HTTP
Set-Cookie: session=abc123; HttpOnly; Secure; SameSite=Lax; Path=/
# Omitting Domain= makes this cookie host-only

__Host- prefix enforces host-only

HTTP
Set-Cookie: __Host-session=abc123; HttpOnly; Secure; SameSite=Lax; Path=/

References

Detected automatically by VulnRadar. The check id is cookie-domain-broad, stable across every scan so you can filter or diff on it.

See every cookies check

Questions

How severe is Cookie Domain Attribute Is Too Broad?
VulnRadar rates this low severity in the cookies category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id cookie-domain-broad, which stays the same between runs so you can filter, diff, or gate CI on it.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for cookie domain attribute is too broad

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Cookie Domain Attribute Is Too Broad | VulnRadar