Bug Description
The express-session middleware in backend/server.js is configured without any cookie options, so the session cookie is issued with browser defaults. This creates three independent attack vectors against every authenticated user.
Affected File
backend/server.js lines 30-33
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
// no cookie options
}));
Attack Surface
1. XSS session hijack (httpOnly absent)
Any JavaScript executing on the page, including an XSS payload or a compromised third-party script, can read the session cookie directly:
document.cookie // returns "connect.sid=s%3A..."
The stolen cookie can be forwarded to an attacker server with a single fetch. Once the cookie is in the attacker's hands they can impersonate the victim for the lifetime of the session.
2. MITM interception (Secure absent)
Without the Secure attribute the browser will transmit the session cookie over plain HTTP. Any passive observer on the same network (coffee shop Wi-Fi, corporate proxy, rogue access point) can read the cookie from an unencrypted request and replay it.
3. Cross-site request forgery (SameSite absent)
Without a SameSite restriction, every cross-origin request the browser makes to this origin (triggered by a link, form, or image on a third-party page) automatically includes the session cookie. This enables CSRF attacks against any state-changing endpoint that relies solely on session authentication.
4. Unbounded session lifetime (maxAge absent)
Without maxAge, the browser creates a session-scoped cookie. Modern browsers restore session state across restarts, so in practice these cookies persist indefinitely rather than expiring after a bounded window.
Steps to Reproduce
- Start the backend (
npm run dev or equivalent).
POST /api/auth/login with valid credentials.
- Open DevTools, go to Application > Cookies.
- Observe the
connect.sid cookie has no HttpOnly, Secure, or SameSite attribute set.
- Confirm from the DevTools console:
document.cookie returns the session ID.
Expected Behavior
The session cookie should be issued with:
httpOnly: true so JavaScript cannot read it
secure: true in production so it is only sent over HTTPS
sameSite: 'strict' so cross-site requests do not carry the cookie
maxAge set to an explicit, bounded expiry (e.g. 24 hours)
Suggested Fix
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'strict',
maxAge: 24 * 60 * 60 * 1000, // 24 hours
},
}));
Severity
Critical / Security - All authenticated user sessions are exposed until this is fixed. No special privilege or access is required to exploit XSS or CSRF vectors; they are reachable from any page on the web.
This issue is raised under GSSoC 2026 for open-source contribution.
Bug Description
The
express-sessionmiddleware inbackend/server.jsis configured without anycookieoptions, so the session cookie is issued with browser defaults. This creates three independent attack vectors against every authenticated user.Affected File
backend/server.jslines 30-33Attack Surface
1. XSS session hijack (
httpOnlyabsent)Any JavaScript executing on the page, including an XSS payload or a compromised third-party script, can read the session cookie directly:
The stolen cookie can be forwarded to an attacker server with a single
fetch. Once the cookie is in the attacker's hands they can impersonate the victim for the lifetime of the session.2. MITM interception (
Secureabsent)Without the
Secureattribute the browser will transmit the session cookie over plain HTTP. Any passive observer on the same network (coffee shop Wi-Fi, corporate proxy, rogue access point) can read the cookie from an unencrypted request and replay it.3. Cross-site request forgery (
SameSiteabsent)Without a
SameSiterestriction, every cross-origin request the browser makes to this origin (triggered by a link, form, or image on a third-party page) automatically includes the session cookie. This enables CSRF attacks against any state-changing endpoint that relies solely on session authentication.4. Unbounded session lifetime (
maxAgeabsent)Without
maxAge, the browser creates a session-scoped cookie. Modern browsers restore session state across restarts, so in practice these cookies persist indefinitely rather than expiring after a bounded window.Steps to Reproduce
npm run devor equivalent).POST /api/auth/loginwith valid credentials.connect.sidcookie has noHttpOnly,Secure, orSameSiteattribute set.document.cookiereturns the session ID.Expected Behavior
The session cookie should be issued with:
httpOnly: trueso JavaScript cannot read itsecure: truein production so it is only sent over HTTPSsameSite: 'strict'so cross-site requests do not carry the cookiemaxAgeset to an explicit, bounded expiry (e.g. 24 hours)Suggested Fix
Severity
Critical / Security - All authenticated user sessions are exposed until this is fixed. No special privilege or access is required to exploit XSS or CSRF vectors; they are reachable from any page on the web.
This issue is raised under GSSoC 2026 for open-source contribution.