How to fix: Cookie Max-Age=0 Deletion Pattern
Max-Age=0 instructs the browser to delete the named cookie immediately. This is the canonical cookie deletion pattern used on logout. Repeated occurrences outside logout endpoints may indicate a double-delete bug.
Why it matters
If Max-Age=0 is emitted on non-logout routes, it may unexpectedly delete user sessions or other cookies, causing functionality failures. If the same cookie is set and deleted in the same response, the deletion takes precedence in some browsers.
Max-Age=0 is the correct and portable way to delete a cookie. However, emitting it outside dedicated logout or session-reset endpoints indicates either a bug or a race condition where a cookie is being both set and deleted in the same response.
How to fix it
- 1Restrict Max-Age=0 Set-Cookie emission to logout and session-reset endpoints only.
- 2Verify no response sets and deletes the same cookie in the same response.
Code examples
Logout endpoint cookie deletion
// Only on the logout endpoint
res.setHeader('Set-Cookie', '__Host-session=; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=0');
res.redirect('/');References
Detected automatically by VulnRadar. The check id is cookie-max-age-zero, stable across every scan so you can filter or diff on it.
More cookies checks
- LowCookie Domain Attribute Is Too Broad
- LowCookie Missing Secure Attribute
- InfoThird-Party Cookie Missing Partitioned Attribute
- High__Host- Prefix Cookie Missing Secure Attribute
- High__Host- Prefix Cookie with Non-Root Path
- High__Secure- Prefix Cookie Missing Secure Attribute
- LowCookie Expires/Max-Age Exceeds 1 Year
- InfoCookie Name Leaks Framework or Language
Questions
- How severe is Cookie Max-Age=0 Deletion Pattern?
- VulnRadar rates this info severity in the cookies 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-max-age-zero, which stays the same between runs so you can filter, diff, or gate CI on it.
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.