Illustration: Prototype pollution can weaken Express session cookies, researcher shows
express-session · Disclosed

Prototype pollution can weaken Express session cookies, researcher shows

· 1 min read

Researcher varanda demonstrated that prototype pollution in Express applications can make the express-session library create session cookies with weakened security attributes, such as httpOnly: false and sameSite: none. The cause is a for...in loop that copies settings and also reads properties inherited through the prototype chain. No fix was cited; set cookie security attributes explicitly and address prototype pollution in the application.

WhatsApp LinkedIn X
MediumVulnerabilityDisclosedFix unconfirmed
In this article
  1. What happened
  2. Why it matters
  3. What to do
  4. For the technical team
  5. Timeline
  6. Sources

What happened

A researcher demonstrated that a prototype pollution flaw in Express applications can make the express-session library issue session cookies with reduced protections, such as httpOnly disabled and sameSite none. This paves the way for CSRF and XSS attacks.

Incidents like this, every morning

The ones that need action first, in a 3-minute read.

Free · 1 email a day, in the morning · no spam, unsubscribe in 1 click

Why it matters

User sessions can be exposed to cookie theft and unauthorized actions on the user's behalf. The issue affects companies whose applications use Express with express-session and that also have a prototype pollution flaw.

What to do

Check that all Express applications explicitly set httpOnly, sameSite, secure and domain on session cookies. Fix prototype pollution sources in the application.

For the technical team

Affected
express-session (biblioteca de sessões para Node.js) · Express applications using the express-session library that are vulnerable to prototype pollution. The source cites no versions.
Exploitation
No exploitation reported. Research published by researcher varanda on dbugs.
Fix
Not cited in the source. Stated mitigation: explicitly set cookie security attributes (httpOnly, sameSite, secure, domain) in the session configuration.
Vector
The express-session library sets secure default values, such as httpOnly: true, then copies application settings into a new object using a for...in loop. That loop also iterates properties inherited through the prototype chain. If the application is vulnerable to prototype pollution, an attacker modifies Object.prototype and new cookies may pick up httpOnly: false and sameSite: none when the developer has not explicitly set those attributes.
More details
Cited consequences: httpOnly false makes session cookies accessible to JavaScript injection, increasing XSS risk; sameSite none allows the browser to send cookies in cross-site requests when Secure requirements are met, creating conditions for CSRF; changing Domain and Secure can expand the cookie's scope or weaken transmission protection. Cited example payload: {"__proto__": {"httpOnly": false, "sameSite": "none"}}.

Timeline

  1. Research by varanda, published on dbugs, detailed the weakness in the library's cookie creation.

Sources 1 source

Get the next one tomorrow morning

One email a day with what changed, what to fix first and how. After signing up you get the full feed.

Free · 1 email a day, in the morning · no spam, unsubscribe in 1 click

Share it with your team

Whoever handles security with you should get it too.

LinkedIn X

Your colleague gets a confirmation request. Nothing is sent unless they confirm.

See all news

Read also

Before you go: get this every day

The HIFY Radar daily edition lands every morning with the incidents that need action. Free.

Free · 1 email a day, in the morning · no spam, unsubscribe in 1 click