Skip to main content
MediumCookies

How to fix: Cookie Domain Scoped to Parent Domain

A cookie is set with Domain= pointing to a parent domain rather than the exact host. This makes the cookie available to all subdomains of the parent domain, including potentially compromised or third-party subdomains.

Why it matters

Any subdomain of the parent domain can read this cookie. A subdomain that is vulnerable to XSS or subject to subdomain takeover can steal the session cookie for the entire domain.

Setting Domain=example.com sends the cookie to every subdomain: www.example.com, api.example.com, dev.example.com, staging.example.com, etc. Each of these subdomains is a potential attack vector. Omitting Domain= restricts the cookie to the exact host that set it.

How to fix it

  1. 1Remove the Domain= attribute to make the cookie host-only.
  2. 2If cross-subdomain sharing is required, use __Host- prefix where possible and audit all receiving subdomains.

Code examples

Host-only (no Domain=)

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

References

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

See every cookies check

Questions

How severe is Cookie Domain Scoped to Parent Domain?
VulnRadar rates this medium 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-set-too-loose, 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 scoped to parent domain

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

Cookie Domain Scoped to Parent Domain fix | VulnRadar