Skip to main content
HighSSLOWASP A02:2021CWE-319

How to fix: Secure Cookie Set on HTTP Endpoint

A Set-Cookie header with the Secure attribute was observed on a plain HTTP response. Browsers silently ignore the Secure flag on non-HTTPS connections, so the cookie is transmitted in cleartext on every subsequent request.

Why it matters

Any network observer can intercept the cookie in cleartext, including session tokens marked Secure, because the browser ignores the Secure flag and sends the cookie over HTTP anyway.

The Secure attribute on a cookie tells the browser to transmit it only over HTTPS. When the server sets a Secure cookie from an HTTP endpoint, the browser still sends the cookie on subsequent HTTP requests to the same origin, defeating the entire purpose of the flag.

How to fix it

  1. 1Serve every page and API endpoint over HTTPS and redirect all HTTP traffic to HTTPS.
  2. 2Never issue a Secure-flagged cookie from an HTTP handler.
  3. 3Enable HSTS to prevent browsers from downgrading future requests.

Code examples

Node.js / Express

JavaScript
// Only set Secure cookies from HTTPS handlers
res.cookie('session', token, {
  httpOnly: true,
  secure: true,   // only effective over HTTPS
  sameSite: 'strict',
  path: '/'
});

Nginx HTTP redirect

nginx
server {
  listen 80;
  server_name example.com;
  return 301 https://$host$request_uri;
}

References

Detected automatically by VulnRadar. The check id is ssl-https-only-cookie-on-http, stable across every scan so you can filter or diff on it.

See every ssl check

Questions

How severe is Secure Cookie Set on HTTP Endpoint?
VulnRadar rates this high severity in the ssl 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 ssl-https-only-cookie-on-http, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Secure Cookie Set on HTTP Endpoint map to?
It maps to CWE-319. In the OWASP Top 10 it falls under A02: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 secure cookie set on http endpoint

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: Secure Cookie Set on HTTP Endpoint | VulnRadar