How to fix: Express session cookie missing security attributes
An Express.js session cookie is set without required security attributes (HttpOnly, Secure, SameSite).
Why it matters
Session cookies without HttpOnly are readable by JavaScript (XSS theft). Without Secure they travel over HTTP (interception). Without SameSite they are sent on cross-site requests (CSRF).
Express session cookies should always include HttpOnly, Secure, and SameSite to protect against the three most common session attack vectors.
How to fix it
- 1Configure express-session with cookie: { httpOnly: true, secure: true, sameSite: "strict" }
- 2Ensure NODE_ENV=production so secure: true is enforced
- 3Use __Host- prefix for the cookie name for additional binding
Code examples
express-session config
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
},
}));References
Detected automatically by VulnRadar. The check id is express-cookie-exposes, stable across every scan so you can filter or diff on it.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
Questions
- How severe is Express session cookie missing security attributes?
- VulnRadar rates this medium severity in the info disclosure 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 express-cookie-exposes, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Express session cookie missing security attributes map to?
- It maps to CWE-614. 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.