Session tokens use secure, HttpOnly, SameSite cookies
Why it matters
Session cookies without the Secure, HttpOnly, and SameSite flags are the most common entry point for session hijacking. Dropping HttpOnly makes the cookie readable by any JavaScript on your page — a single XSS flaw anywhere on the domain hands an attacker every active session. Dropping Secure lets the cookie travel over unencrypted HTTP connections, where network attackers can intercept it. Missing SameSite exposes the session to CSRF attacks. Together these flags implement the three-sided defense OWASP A07 (Identification & Authentication Failures) and NIST 800-63B expect as a baseline for any session credential.
Severity rationale
High because missing any one of these three flags creates a direct, exploitable path to session token theft and full account takeover.
Remediation
Set all three flags explicitly in your auth library config rather than relying on defaults. In NextAuth, override the cookie options block:
// src/app/api/auth/[...nextauth]/route.ts
export const authOptions = {
cookies: {
sessionToken: {
options: {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
path: '/'
}
}
}
}
For Supabase, use @supabase/ssr — it handles all three flags correctly. For any custom Set-Cookie header, append ; HttpOnly; Secure; SameSite=Lax before every response.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Authentication Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-614 — Sensitive Cookie in HTTPS Session Without 'Secure' Attribute
- cwe · CWE-1004 — Sensitive Cookie Without 'HttpOnly' Flag
- owasp:2021 · A07
- nist:rev5 · SC-8
- soc2:2017 · CC6.1 — Logical access security software, infrastructure, and architectures
- soc2:2017 · CC6.7 — Restriction of information transmission, movement, and removal
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-authentication·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.1, CC6.7) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2