Session cookies have Secure and HttpOnly flags
Why it matters
Session cookies without Secure can be transmitted over plain HTTP if a downgrade or redirect is ever triggered, handing an attacker the session token in cleartext. Cookies without HttpOnly are readable by any JavaScript on the page — a single XSS payload is enough to exfiltrate the token to an attacker-controlled server. Together, these two flags prevent the most common session-theft vectors. OWASP A05 (Security Misconfiguration) and A07 (Identification and Authentication Failures) both flag missing cookie security attributes as prerequisites for session hijacking. CWE-614 and CWE-1004 explicitly name the absence of Secure and HttpOnly as exploitable defects.
Severity rationale
High because missing Secure or HttpOnly flags on session cookies are direct prerequisites for session hijacking via network interception or XSS.
Remediation
Verify your auth library's cookie configuration explicitly sets both flags. Most libraries set them by default in production, but explicit config overrides defaults and survives library upgrades without silent regression.
// NextAuth.js — src/app/api/auth/[...nextauth]/route.ts or auth.ts
export const authOptions = {
cookies: {
sessionToken: {
options: { httpOnly: true, secure: true, sameSite: 'lax' }
}
}
}
For manual Set-Cookie headers in API routes, append ; HttpOnly; Secure; SameSite=Lax to every cookie value. Search all API routes for Set-Cookie and document.cookie to find uncovered locations.
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 Security Headers & Basics 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 · A05 — Security Misconfiguration
- owasp:2021 · A07 — Identification and Authentication Failures
- soc2:2017 · CC6.7 — Restriction of information transmission, movement, and removal
Taxons
History
- 2026-04-17·v1.0.0·Initial import from security-headers·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.7) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2