Skip to main content
MediumInfo disclosureOWASP A05:2021CWE-614

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

  1. 1Configure express-session with cookie: { httpOnly: true, secure: true, sameSite: "strict" }
  2. 2Ensure NODE_ENV=production so secure: true is enforced
  3. 3Use __Host- prefix for the cookie name for additional binding

Code examples

express-session config

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

See every info disclosure check

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.

Propose a checkHow a check is built

Scan your own site for express session cookie missing security attributes

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

Express session cookie missing security attributes | VulnRadar