← Blog

Claude MCP skill session management vulnerabilities — developer portal authentication — SA-SKL-AUTH12

Session management is the scaffolding on which authentication rests. A correctly validated login flow is undermined by cookies that XSS can steal, CSRF that cross-site forms can exploit, session fixation that pre-places an attacker-known session ID before login, and persistent sessions that survive a password reset. SA-SKL-AUTH12 covers four session management flaws that SkillAudit finds in MCP skill registry developer portals — all exploitable without breaking the login logic itself.

By SkillAudit  |  12 Nov 2026
SA-SKL-AUTH12 findings at a glance
HIGHAUTH12-001 — session cookie without HttpOnly — attacker XSS reads document.cookie and exfiltrates session token; persistent account takeover
HIGHAUTH12-002 — session cookie without SameSite=Strict — cross-site form submission sends session cookie; CSRF modifies account settings or deletes skills
CRITICALAUTH12-003 — session fixation — attacker pre-places known session ID; victim logs in; attacker now has authenticated session without credentials
HIGHAUTH12-004 — sessions not invalidated on password change — attacker with stolen session retains access after victim resets password

AUTH12-001 — Session cookie without HttpOnly flag

The HttpOnly cookie flag prevents JavaScript from reading a cookie via document.cookie. Without it, any XSS vulnerability in the application — including a stored XSS in a skill name or description that the registry renders — can directly exfiltrate the session token. The token then persists until the session expires or the user explicitly logs out, giving the attacker ongoing access.

// VULNERABLE — AUTH12-001
// express-session configured without httpOnly: true
// (httpOnly defaults to true in express-session, but explicit false is common in legacy configs)

app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false,
  cookie: {
    secure: true,
    httpOnly: false,  // VULNERABLE: JavaScript can read document.cookie
    maxAge: 7 * 24 * 60 * 60 * 1000,
  }
}));
// FIXED — AUTH12-001
app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false,
  cookie: {
    secure: true,
    httpOnly: true,         // FIX: JavaScript cannot read this cookie
    sameSite: 'strict',     // also fixes AUTH12-002
    maxAge: 7 * 24 * 60 * 60 * 1000,
  }
}));

AUTH12-002 — Session cookie without SameSite=Strict and missing CSRF token

Without SameSite=Strict (or Lax at minimum), a session cookie is sent on cross-site requests including form submissions from attacker-controlled pages. An attacker hosts a page containing an auto-submitting form that POST to /api/skills/delete?id=...<victim-skill-id>. When the victim visits the attacker's page while logged in, the browser sends the session cookie with the form request. The registry deletes the skill with no interaction from the developer.

// VULNERABLE — AUTH12-002
// No SameSite cookie attribute; no CSRF token on state-changing forms

app.use(session({
  secret: process.env.SESSION_SECRET,
  cookie: {
    secure: true,
    httpOnly: true,
    // VULNERABLE: sameSite not set — defaults to 'lax' in browsers but explicit
    // 'none' is sometimes set for OAuth callback compatibility, leaving CSRF exposure
    sameSite: 'none',
    secure: true, // required when sameSite:'none'
  }
}));

// No CSRF token generated or validated on /api/skills/delete
app.delete('/api/skills/:id', requireAuth, async (req, res) => {
  await db.skills.delete(req.params.id, req.user.orgId);
  res.json({ ok: true });
});
// FIXED — AUTH12-002
// SameSite:'strict' for session cookie.
// CSRF token validated on all state-changing requests.

const csrf = require('csurf');
const csrfProtection = csrf({ cookie: false }); // token in session, not cookie

app.use(session({
  secret: process.env.SESSION_SECRET,
  cookie: {
    secure: true,
    httpOnly: true,
    sameSite: 'strict',   // FIX: cross-site requests do not include this cookie
  }
}));

// Generate CSRF token for forms
app.get('/dashboard', requireAuth, csrfProtection, (req, res) => {
  res.render('dashboard', { csrfToken: req.csrfToken() });
});

// Validate CSRF token on state-changing routes
app.delete('/api/skills/:id', requireAuth, csrfProtection, async (req, res) => {
  await db.skills.delete(req.params.id, req.user.orgId);
  res.json({ ok: true });
});

AUTH12-003 — Session fixation

Session fixation is an attack where the attacker plants a known session ID before the victim logs in. When the victim authenticates, the application continues using the same session ID rather than generating a new one. The attacker, who already knows the session ID, can now send requests authenticated as the victim without ever obtaining their credentials. The fix is a single call to req.session.regenerate() immediately after successful authentication — this creates a fresh session ID while preserving the session data.

// VULNERABLE — AUTH12-003
// Login handler reuses the existing session ID after authentication.
// Attacker injects a known session ID via cookie manipulation before the victim visits login.

app.post('/auth/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.users.findByEmail(email);
  if (!user || !await bcrypt.compare(password, user.passwordHash)) {
    return res.status(401).json({ error: 'invalid credentials' });
  }
  // VULNERABLE: session ID is not regenerated — existing session ID is reused
  req.session.userId = user.id;
  req.session.orgId = user.orgId;
  res.json({ ok: true });
});
// FIXED — AUTH12-003
// regenerate() creates a new session ID and migrates session data.
// Attacker's pre-planted session ID is invalidated.

app.post('/auth/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.users.findByEmail(email);
  if (!user || !await bcrypt.compare(password, user.passwordHash)) {
    return res.status(401).json({ error: 'invalid credentials' });
  }

  // FIX: regenerate session to prevent session fixation
  req.session.regenerate((err) => {
    if (err) return res.status(500).json({ error: 'session error' });
    req.session.userId = user.id;
    req.session.orgId = user.orgId;
    res.json({ ok: true });
  });
});

AUTH12-004 — Sessions not invalidated on password change

When a user changes their password (either voluntarily or as part of a compromised-account recovery), all existing sessions should be invalidated except the one performing the change. Without this, an attacker who stole a session token continues to have full access to the account after the victim has changed their password — which is typically the user's first response to a suspected account compromise. The session token they stole remains valid indefinitely (or until its natural expiry), negating the entire recovery action.

// VULNERABLE — AUTH12-004
// Password change updates only the password hash in the database.
// Existing sessions (including attacker's stolen session) remain valid.

app.post('/api/account/change-password', requireAuth, async (req, res) => {
  const { currentPassword, newPassword } = req.body;
  const user = await db.users.findById(req.session.userId);
  if (!await bcrypt.compare(currentPassword, user.passwordHash)) {
    return res.status(400).json({ error: 'incorrect current password' });
  }
  const newHash = await bcrypt.hash(newPassword, 12);
  await db.users.updatePasswordHash(user.id, newHash);
  // VULNERABLE: no session invalidation — attacker's stolen session persists
  res.json({ ok: true });
});
// FIXED — AUTH12-004
// Increment sessionVersion on password change.
// All sessions with old sessionVersion are rejected.
// Current session is updated to new sessionVersion — user stays logged in.

// In session validation middleware:
app.use(async (req, res, next) => {
  if (!req.session.userId) return next();
  const user = await db.users.findById(req.session.userId);
  if (!user) { req.session.destroy(); return res.status(401).json({ error: 'unauthenticated' }); }
  // FIX: reject sessions with old sessionVersion
  if (req.session.sessionVersion !== user.sessionVersion) {
    req.session.destroy();
    return res.status(401).json({ error: 'session invalidated — please log in again' });
  }
  req.user = user;
  next();
});

app.post('/api/account/change-password', requireAuth, async (req, res) => {
  const { currentPassword, newPassword } = req.body;
  if (!await bcrypt.compare(currentPassword, req.user.passwordHash)) {
    return res.status(400).json({ error: 'incorrect current password' });
  }
  const newHash = await bcrypt.hash(newPassword, 12);
  // FIX: increment sessionVersion — invalidates all existing sessions
  const newVersion = req.user.sessionVersion + 1;
  await db.users.updatePasswordAndVersion(req.user.id, newHash, newVersion);
  // FIX: update current session to new version — current user stays logged in
  req.session.sessionVersion = newVersion;
  res.json({ ok: true });
});

Alternative: store all sessions in Redis and delete by user ID: If you store session data in Redis keyed by session ID, you can maintain a secondary index user:{userId}:sessions that maps user IDs to session keys. On password change, iterate the index and DEL all session keys except the current one. This is more explicit and easier to audit than the sessionVersion counter approach, but requires a Redis session store rather than the default in-memory or cookie-based store.

Summary — SA-SKL-AUTH12 at a glance

PatternRoot causeFixSeverity
AUTH12-001Session cookie missing HttpOnly flag — readable by XSShttpOnly: true on all session cookiesHIGH
AUTH12-002Missing SameSite=Strict — CSRF on state-changing formssameSite: 'strict' + csurf token on mutationsHIGH
AUTH12-003Session ID not regenerated on login — fixation attackreq.session.regenerate() immediately after successful authCRITICAL
AUTH12-004Sessions not invalidated on password change — stolen session persistsIncrement sessionVersion counter; validate in auth middlewareHIGH

See also SA-SKL-AUTH11 (OAuth PKCE and CSRF bypass) and SA-SKL-AUTH10 (API key scope bypass) for related authentication patterns in MCP skill registries.