Skip to main content
MediumCookiesOWASP A05:2021CWE-1004

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

  1. 1Add HttpOnly to all session, authentication, and CSRF cookies.
  2. 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

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

Node.js response.cookie()

JavaScript
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.

See every cookies check

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.

Propose a checkHow a check is built

Scan your own site for cookie missing httponly attribute

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 Missing HttpOnly Attribute | VulnRadar