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
- 1Serve every page and API endpoint over HTTPS and redirect all HTTP traffic to HTTPS.
- 2Never issue a Secure-flagged cookie from an HTTP handler.
- 3Enable HSTS to prevent browsers from downgrading future requests.
Code examples
Node.js / Express
// 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
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.
More ssl checks
- CriticalSite Served Over Unencrypted HTTP
- InfoExpect-CT Header Not Present
- LowHTTPS Served on Non-Standard Port
- InfoX-HTTP-Method-Override / X-Forwarded-Method Header in Response
- InfoHSTS Present on HTTP Response (SSL-Strip Indicator)
- MediumMixed-Protocol Content (HTTPS Page Loading HTTP Resources)
- LowHSTS declared in a meta tag, where browsers ignore it
- MediumAlt-Svc advertises cleartext HTTP/2 (h2c)
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.