Skip to main content
HighCookiesOWASP A05:2021CWE-1004

How to fix: JWT-Shaped Cookie Missing HttpOnly

A cookie whose value has the three-part base64url.base64url.base64url shape of a JWT is missing the HttpOnly attribute.

Why it matters

Any script running on the page, including one injected via XSS or a compromised third-party dependency, can read document.cookie and exfiltrate the token, giving the attacker a valid, unexpired session.

A cookie value matching the JWT structure is almost always a session or access token. Storing it without HttpOnly makes it readable from JavaScript, which defeats the entire point of using a cookie (rather than localStorage) as the storage mechanism in the first place.

How to fix it

  1. 1Set the HttpOnly attribute on any cookie carrying a JWT or other bearer token.
  2. 2If client-side JavaScript genuinely needs to read the token, split it: keep the signature in an HttpOnly cookie and issue a separate non-sensitive value for JS to read.

Code examples

Set HttpOnly on a JWT cookie

text
Set-Cookie: access_token=eyJhbGciOi...; HttpOnly; Secure; SameSite=Lax; Path=/

References

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

See every cookies check

Questions

How severe is JWT-Shaped Cookie Missing HttpOnly?
VulnRadar rates this high 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-jwt-value-not-httponly, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does JWT-Shaped Cookie Missing HttpOnly 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 jwt-shaped cookie missing httponly

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: JWT-Shaped Cookie Missing HttpOnly | VulnRadar