Skip to main content
LowConfigCWE-1275

How to fix: Set-Cookie Header Exceeds 4 KB

A Set-Cookie header is larger than 4 KB. Browsers silently drop cookies that exceed this limit, causing unpredictable session behavior.

Why it matters

When the browser drops an oversized cookie, the user loses their session and may be redirected to login unexpectedly. If the cookie carries signed state, its loss may bypass security checks that rely on the cookie being present.

Browsers enforce a 4 KB limit on individual cookie size. Exceeding this limit causes the browser to silently discard the cookie. If the session or authentication state lives in the cookie, the user appears logged out even though the server issued a valid session.

How to fix it

  1. 1Move large payloads (e.g., user profile data, permissions) to server-side session storage.
  2. 2Store only the session ID in the cookie; look up the rest server-side on every request.
  3. 3Use a signed, encrypted session token (JWE) only for data that must survive across server restarts.

Code examples

Server-side session (Node.js/Express)

JavaScript
import session from 'express-session';
import RedisStore from 'connect-redis';

app.use(session({
  store: new RedisStore({ client: redisClient }),
  secret: process.env.SESSION_SECRET,
  name: '__Host-sid',
  cookie: {
    httpOnly: true,
    secure: true,
    sameSite: 'lax',
    maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days
  },
}));

References

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

See every config check

Questions

How severe is Set-Cookie Header Exceeds 4 KB?
VulnRadar rates this low severity in the config 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-too-large, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Set-Cookie Header Exceeds 4 KB map to?
It maps to CWE-1275.

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 set-cookie header exceeds 4 kb

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: Set-Cookie Header Exceeds 4 KB | VulnRadar