Overly Broad Cookie Scope
A sensitive cookie is scoped to a parent domain or an over-broad path, so the browser also sends it to other hosts or applications that should not receive it.
| Severity | Low |
| CVSS 3.1 | 3.1 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 2.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-668: Exposure of Resource to Wrong Sphere |
| OWASP Top 10 | A01:2025 Broken Access Control |
| MITRE ATT&CK | T1539 Steal Web Session Cookie |
| Category | Security Misconfiguration |
Description
The application sets a sensitive cookie, such as a session identifier, with a Domain attribute naming a parent domain, for example the organisation's main domain rather than the application's own host name. A cookie with a Domain attribute is sent to that domain and to every subdomain of it, so every other host under the domain receives the cookie with each request, and script on any of them can read it unless it is HttpOnly. A cookie set without a Domain attribute is sent only to the host that set it.
An attacker who controls any one of those hosts, whether through cross-site scripting or another flaw on a less well protected site, a subdomain takeover of a name still pointing at a decommissioned service, or because a third party operates that host, can capture the cookie and hijack the user's session in the application. The risk grows with the number and variety of hosts under the domain, particularly where some are run by other teams or suppliers, and is low where the domain holds a few well-maintained hosts.
A related form is a Path attribute broader than the application needs where several applications share one host name under different paths. The path is not a security boundary between pages of the same origin, because script on one path can read cookies for another through a frame, so applications that need to be isolated from each other need separate host names.
The issue is identified by inspecting the Domain and Path attributes in the Set-Cookie headers and by reviewing which other hosts exist under the domain, for example from DNS records and certificate transparency logs.
Remediation
Scope sensitive cookies as narrowly as the application allows:
- Omit the
Domainattribute on session and authentication cookies, so that they are sent only to the host that set them. Where a cookie genuinely must be shared between hosts, name the narrowest common domain and hold every host under it to the same standard. - Use the
__Host-name prefix for session cookies: browsers only accept such a cookie when it hasSecure,Path=/and noDomainattribute, so its scope cannot be widened by mistake and other hosts cannot set a cookie of that name for it. - Run applications that must be isolated from each other on separate host names rather than separate paths of one host.
- Review the hosts under the domain, remove DNS records that point at decommissioned services, and move sites operated by third parties to a separate domain where practical.
- Where users need single sign-on across hosts, use a federation protocol such as OpenID Connect or SAML rather than a session cookie shared across the domain.
Confirm the fix by checking that session cookies are set without a Domain attribute and are not sent to other hosts under the domain.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.