CWE-614: Insecure Cookie Flags
A session cookie is set without the Secure, HttpOnly, or SameSite flags, so it can be stolen over plain HTTP, read by scripts, or sent in cross-site requests.
Also known as: Missing Secure flag, Missing HttpOnly, Insecure cookie attributes
Risk
Usually medium to high. A session cookie without the right flags can be intercepted over HTTP, stolen by injected JavaScript, or replayed across sites, each a direct path to session hijacking.
Definition
What it is
CWE-614 is the omission of protective attributes on a sensitive cookie. Without Secure, the cookie travels over plain HTTP where it can be sniffed. Without HttpOnly, any cross-site-scripting payload can read it from JavaScript. Without an appropriate SameSite value, the browser attaches it to cross-site requests, enabling cross-site request forgery. These flags are the browser-level guardrails around the session token, and leaving them off exposes the token to the most common theft paths.
Use-cases
How it shows up in real code
No Secure flag over HTTP
A session cookie lacks Secure, so the browser sends it on an http request to the same domain. Anyone on the network path reads the token and hijacks the session.
No HttpOnly meets XSS
The cookie is readable from JavaScript, and the site has a cross-site-scripting hole. The injected script reads document.cookie and exfiltrates the session token.
Missing SameSite enables CSRF
Without SameSite, the browser attaches the session cookie to a request triggered from an attacker's page. The forged request runs as the logged-in user.
Cookie scoped too broadly
The cookie is set for the parent domain with no path or host restriction. A less trusted subdomain can now read the main session token.
AI risk
Why AI-generated code has increased the exposure
- Assistants optimize for a cookie that works in local development over http, so they omit Secure, which would stop the cookie from being set without TLS.
- Many training examples set a cookie with just a name and value, so the model reproduces the bare set-cookie without HttpOnly or SameSite.
- The model cannot see that the app runs behind HTTPS in production, so it leaves off flags that its local http context would otherwise break.
- When scaffolding login, the assistant writes the cookie that stores the session but not the hardening attributes that protect it.
- Generated code tends to pick permissive SameSite or none to make cross-origin flows work in a demo, weakening the CSRF protection for everyone.
Vibe coding
How vibe coding amplifies the risk
- Vibe coding ships the bare cookie the assistant wrote, and a cookie that works needs no flags to look correct.
- The skipped review is where someone would check that the session cookie carries Secure, HttpOnly, and SameSite.
- A prototype that set cookies over http for convenience is promoted to production without the Secure flag ever being added.
- The gap is invisible in local and demo testing because the attacks (network sniffing, XSS theft, CSRF) are never exercised on localhost.
- As a vibe-coded site attracts real traffic and an eventual XSS or hostile network, the unhardened cookie becomes the easiest token to steal.
Detection
How to find it
- Inspect the Set-Cookie headers for session cookies and confirm Secure, HttpOnly, and an appropriate SameSite are all present.
- Check whether the cookie is sent over plain http to the domain, which proves Secure is missing.
- Read document.cookie in the browser console; seeing the session cookie proves HttpOnly is absent.
- Review the cookie's domain and path scope to ensure it is not shared more broadly than needed.
Remediation
How to fix it
- Set Secure on every sensitive cookie so it is only ever sent over HTTPS.
- Set HttpOnly on session cookies so client-side scripts cannot read them.
- Set SameSite to Lax or Strict as the flow allows, reserving None with Secure only for genuine cross-site needs.
- Scope cookies to the narrowest host and path, and prefix names with __Host- where supported.
- Serve the whole site over HTTPS with HSTS so cookies never have a plain-HTTP path to leak on.
Frequently asked questions
- What is CWE-614 (sensitive cookie without secure attribute)?
- CWE-614 is when a session or other sensitive cookie is set without protective flags, so it can be sniffed over plain HTTP without Secure, read by injected scripts without HttpOnly, or sent on cross-site requests without SameSite. Each missing flag opens a direct path to stealing or abusing the session.
- How have AI assistants and vibe coding increased the risk?
- Assistants optimize for a cookie that works in local http development and reproduce bare set-cookie examples, so they omit Secure, HttpOnly, and SameSite, and sometimes pick permissive values to make demos work. Vibe coding ships those cookies unread, and since the relevant attacks never run on localhost, the unhardened cookie reaches production.
- How do I fix insecure cookie flags?
- Set Secure and HttpOnly on session cookies, choose a strict SameSite value, scope the cookie to the narrowest host and path with a __Host- prefix where possible, and serve the site over HTTPS with HSTS.
Related weaknesses
Catch CWE-614 before you ship
Tethlyn Audit scans your codebase and its git history for CWE-614 and the rest of the authentication & session security class, then ranks each finding by real exploitability and data sensitivity.