How to fix: Cookie Missing HttpOnly Attribute
A session or authentication cookie is set without the HttpOnly attribute. Without HttpOnly, the cookie is accessible to JavaScript via document.cookie, making it stealable by any XSS vulnerability on the page.
Why it matters
A single XSS vulnerability anywhere on the site can steal all non-HttpOnly cookies. An attacker who exfiltrates the session cookie can authenticate as the victim from a different device, bypassing all client-side controls.
HttpOnly prevents JavaScript (including injected malicious scripts) from accessing the cookie via document.cookie. The cookie is still sent automatically by the browser on every HTTP request, so it works identically for server-side session management. Only browser JavaScript access is blocked.
How to fix it
- 1Add HttpOnly to all session, authentication, and CSRF cookies.
- 2Only omit HttpOnly for cookies that must be read by client-side JavaScript (e.g., a CSRF token that JS reads to include in request headers).
Code examples
Set-Cookie with HttpOnly
Set-Cookie: __Host-session=abc123; HttpOnly; Secure; SameSite=Lax; Path=/Node.js response.cookie()
res.cookie('__Host-session', token, {
httpOnly: true,
secure: true,
sameSite: 'lax',
path: '/',
});References
Detected automatically by VulnRadar. The check id is cookie-httponly-missing, stable across every scan so you can filter or diff on it.
More cookies checks
- LowCookie Domain Attribute Is Too Broad
- LowCookie Missing Secure Attribute
- InfoThird-Party Cookie Missing Partitioned Attribute
- High__Host- Prefix Cookie Missing Secure Attribute
- High__Host- Prefix Cookie with Non-Root Path
- High__Secure- Prefix Cookie Missing Secure Attribute
- LowCookie Expires/Max-Age Exceeds 1 Year
- InfoCookie Name Leaks Framework or Language
Questions
- How severe is Cookie Missing HttpOnly Attribute?
- 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-httponly-missing, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Cookie Missing HttpOnly Attribute map to?
- It maps to CWE-1004. In the OWASP Top 10 it falls under A05:2021.
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.