Cookie without Secure or HttpOnly flag: is it real, how to fix it, what to tell the customer
Facts
- Scanner finding
- KB-F-0005 · Web and API, SaaS team security
- Also known as
- Cookie Without Secure Flag, Cookie No HttpOnly Flag
- Tool IDs
- ZAP 10011 "Cookie Without Secure Flag" and 10010 "Cookie No HttpOnly Flag" (passive, Low); often with ZAP 10054-1 "Cookie without SameSite Attribute". Burp 0x00500200 "TLS cookie without secure flag set" and 0x00500600 "Cookie without HttpOnly flag set". Nessus 85602 "Web Application Cookies Not Marked Secure" and 85601 "Web Application Cookies Not Marked HttpOnly"
- Standard
- RFC 6265 §4.1.2.5 and §4.1.2.6; draft-ietf-httpbis-rfc6265bis-22
- Lab
- scanner-findings, last run 2026-11-26 (run 8): nginx 1.30.8, Apache httpd 2.4.71, Express 5.3.0, express-session 1.19.0, ZAP 2.17.0, images pinned by digest
- Test
tests/cookie-flags.sh url [names], fails on the vulnerable target, passes after the fix- Next review
- 2027-05-28
Short answer
These findings (ZAP 10011 and 10010, Burp 0x00500200 and 0x00500600, Nessus 85602 and 85601) mean a Set-Cookie header lacked Secure, so the browser may send the cookie over plain HTTP, or lacked HttpOnly, so page scripts can read it. For session cookies both findings are real and the fix is one option. For a cookie your front end must read, HttpOnly would break it: keep Secure and accept the rest. Behind a TLS proxy, Express sessions with secure: true need trust proxy, or the cookie is never sent.
1. What the scanner saw
Each tool reads the Set-Cookie headers in responses. ZAP 10011 checks only responses to HTTPS requests, since a cookie set over plain HTTP cannot usefully be marked Secure (rule source). ZAP 10010 checks every response. Both skip cookies that are already expired, such as a logout that deletes a cookie. Both are rated Low. Burp rates the Secure case Medium and the HttpOnly case Low. Tenable rates both Nessus plugins Info.
The tools do not know what a cookie is for. A theme preference and a session ID get the same alert. That is the main source of disagreement between scanner and team.
2. Is it real on your system?
curl -sI https://app.example.com/login | grep -i '^set-cookie'
Do it for the URLs in the report, and for the response after a real login (session cookies often appear only then; use the browser's developer tools, Network tab, if login needs a form). Each line shows the attributes, for example sid=...; Path=/; HttpOnly; Secure; SameSite=Lax.
Then sort the cookies:
Session, login, "remember me", CSRF secret on the server side: must have
SecureandHttpOnly. A missing flag is a real finding.Read by your own JavaScript: for example a CSRF token that the front end copies into a request header (the double-submit pattern), or a consent cookie read by a banner script.
HttpOnlywould break it. KeepSecure. This is the usual "false positive" for 10010, though the alert is technically accurate.Set by a third-party script: ZAP and Burp see only
Set-Cookieheaders in your responses, so cookies written by scripts in the browser do not appear in these alerts. If the report names one, it came from your server or a service you proxy.
Two traps we reproduced:
Express session cookie disappears behind a proxy. With express-session
cookie: { secure: true }behind a TLS-terminating nginx and notrust proxy, our target sent noSet-Cookieat all. The login page loaded and the user was never logged in. express-session documents this: behind a proxy withsecure: true, settrust proxy(express-session). Withapp.set('trust proxy', 1)the cookie came back withHttpOnly; Secure; SameSite=Lax. A team that tried the fix, saw login break and reverted it may be looking at exactly this.The app sets the cookie, the proxy can fix it, and can break it. Our proxy target forwarded a cookie without flags and added them with nginx
proxy_cookie_flags(below). Withsamesite=laxin that line, nginx also rewrote an upstreamssocookie fromSameSite=NonetoSameSite=Lax. Cross-site sign-in callbacks and embedded widgets that needNonestop working, and a flag check alone still passes.
3. How serious it is for you
Our view: for a session cookie, missing Secure is the more important half. If any page on the domain still answers on plain HTTP, or a user types the bare domain on a hostile network, the browser sends the cookie in clear text. RFC 6265 says a Secure cookie is sent only "if the request is transmitted over a secure channel" (RFC 6265 §4.1.2.5). HSTS reduces the same risk once the browser has visited over HTTPS; set both.
Missing HttpOnly matters when someone finds a cross-site scripting bug: with HttpOnly, the browser omits the cookie from "non-HTTP" APIs such as document.cookie (RFC 6265 §4.1.2.6), so the script cannot copy the session out. It does not stop the script from acting inside the page. It is a cheap second line, and customers expect it on session cookies.
Accepted risk is reasonable for cookies that hold no secret and must be read by your front end. Name them in the reply.
4. Fix it on your platform
The target for a session cookie: Secure; HttpOnly; SameSite=Lax (or Strict), Path=/. Consider the __Host- name prefix: a browser accepts a __Host- cookie only with Secure, Path=/ and no Domain attribute (6265bis-22 §4.1.3.2). The draft is in the RFC Editor queue, not yet an RFC.
Express and Node.js (lab-tested on Express 5.3.0, express-session 1.19.0)
res.cookie('sid', value, { secure: true, httpOnly: true, sameSite: 'lax', path: '/' });
The Express documentation lists no default for httpOnly or secure and says unset options follow RFC 6265, which means both flags are absent (Express res.cookie). Our vulnerable target, res.cookie('sid', value, { path: '/' }), sent sid=lab-session-0001; Path=/ with no flags.
With express-session, HttpOnly is on by default and Secure is off (express-session):
app.set('trust proxy', 1); // when TLS ends at a proxy or load balancer
app.use(session({ secret: process.env.SESSION_SECRET, cookie: { secure: true, httpOnly: true, sameSite: 'lax' } }));
nginx (lab-tested on 1.30.8)
For cookies that nginx sets itself, write the flags into the header (the value is the lab's placeholder):
add_header Set-Cookie "sid=lab-session-0001; Path=/; Secure; HttpOnly; SameSite=Lax";
For cookies that an upstream application sets, nginx 1.19.3 and later can add flags on the way out (nginx proxy_cookie_flags):
location / {
proxy_pass http://app:3000;
proxy_cookie_flags ~ secure httponly;
}
Leave samesite=... out of the catch-all line: nginx replaces an existing SameSite value, so samesite=lax turns a SameSite=None cookie into Lax. In our lab the line above kept SameSite=None on the sso cookie and added both flags to sid. Set SameSite in the application, or add a line for a named cookie only.
A cookie name that starts with ~ is a regular expression, and a bare ~ applies to every cookie, as in the nginx documentation's own example. When several lines match a cookie, the first one wins, so put a line such as proxy_cookie_flags XSRF-TOKEN secure; before the catch-all for a cookie that scripts must read. Fixing it in the app is better in the long run; the proxy line is a fast stopgap that we tested.
Apache httpd (lab-tested on 2.4.71)
Header edit rewrites a header value with a regular expression (mod_headers). Our own lines, for a proxied application whose session cookie is named sid, one line per flag:
Header edit Set-Cookie "(?i)^(sid=(?!.*;\s*secure).*)$" "$1; Secure"
Header edit Set-Cookie "(?i)^(sid=(?!.*;\s*httponly).*)$" "$1; HttpOnly"
They name the cookie, so cookies that scripts must read are left alone, and each line adds its flag only when it is missing, in any letter case. One line for both flags is not enough: an app behind HTTPS often sets Secure but not HttpOnly, and a single line that skips cookies with Secure left our lab cookie sid=lab-session-0001; Path=/; Secure without HttpOnly. With the two lines the test passed for that cookie and for one without flags. Use Header edit without always for ProxyPass applications: in our lab, Header always edit left the proxied cookie unchanged and the test failed. The documentation explains why: headers from CGI scripts and mod_proxy_fcgi sit in the always table, so for a PHP-FPM or CGI application use always, and test with cookie-flags.sh either way. Prefer setting the flags in the application.
IIS and ASP.NET (from documentation, not run by us)
For ASP.NET applications on .NET Framework, the system.web/httpCookies section sets defaults for all cookies the application issues: httpOnlyCookies, requireSSL and sameSite (HttpCookiesSection). Code that sets a cookie explicitly can override them, and the forms-authentication cookie follows <forms requireSSL> rather than httpCookies (httpCookies element).
Netlify (from documentation, not run by us)
Netlify lists Set-Cookie among headers whose custom values are "typically ignored" and says it "may be overridden by Netlify cookie handling" (Netlify custom headers), so on Netlify the fix belongs in the code that sets the cookie.
5. What to tell the customer
Example wording, adapt to what is true.
Fixed:
Thank you for the report. Our session cookie
sidis now set withSecure,HttpOnlyandSameSite=Lax. Attached is theSet-Cookieheader after login, captured on.
Partly accepted:
sid(the session) now hasSecureandHttpOnly.XSRF-TOKENis read by our front end and copied into a request header as CSRF protection, so it cannot beHttpOnly. It carriesSecureandSameSite=Lax, holds no session data, and the server checks it against the session.themestores a display preference only.
Evidence to attach: the Set-Cookie lines for every cookie named in the report, after login, with the date.
6. Test: fails before the fix, passes after
Our script cookie-flags.sh, run as sh cookie-flags.sh url [names], reads every Set-Cookie on the response.
Pass rule, written before the run: exit 1 when any cookie lacks
Secure, or lacksHttpOnlyunless its name is in the comma-separated list, and also when the URL sets no cookie at all, since then nothing was tested. WithSAMESITE_NONE=name1,name2set, it also fails when one of those cookies has any SameSite value other thanNone, which catches a proxy rewrite. It prints the SameSite value of every cookie. Exit 0 otherwise. Exit 2, not tested, when the URL cannot be reached or does not answer with HTTP.Run it on your host: remove
-kfor a real site, thensh cookie-flags.sh https://app.example.com/login XSRF-TOKEN. Point it at a URL that sets the session cookie without a form post, or extend it to post your test user's login. It needs a POSIX shell,curl,awk,grep,sed,trandhead, and exits 2 if one is missing; we ran it with GNU tools and with BusyBox.What the test cannot detect: cookies set only after a form login or on other URLs (it sends one GET to the URL you give); cookies written by JavaScript; whether a cookie it lists without
HttpOnlyreally needs to be readable; whether the SameSite value is right for cookies you did not put inSAMESITE_NONE;Domainscope and expiry. It reads header names in any case and attributes with any spacing, as browsers do.
7. What we ran
Run 8, 2026-11-26: nginx 1.30.8, Apache httpd 2.4.71, Express 5.3.0, images pinned by digest. Every test ran from a GNU and a BusyBox client with the same exit codes, and once more with one required tool removed from PATH, which gave "not tested" (exit 2) every time.
| Target | Setup | Our test | ZAP baseline |
|---|---|---|---|
| ngx-vuln | Set-Cookie: sid=...; Path=/ |
fail: lacks Secure, HttpOnly | 10011, 10010, 10054-1 on /login |
| ngx-fixed | flags in the header | pass | none of them |
| app-vuln (Express) | res.cookie('sid', v, { path: '/' }) |
fail | 10011, 10010, 10054-1 on /login |
| app-fixed | { secure, httpOnly, sameSite: 'lax' } |
pass | none of them |
| app-partial | sid fixed, pref without flags |
fail on pref |
not scanned |
| proxy 9443 | app without flags, proxy_cookie_flags ~ secure httponly samesite=lax |
pass | not scanned |
| proxy 12443 | same line, app also sets sso with SameSite=None, SAMESITE_NONE=sso |
fail: sso rewritten to Lax |
not scanned |
| proxy 13443 | proxy_cookie_flags ~ secure httponly, same app |
pass: sso keeps None, sid gets both flags |
not scanned |
| proxy 443 | express-session secure: true, no trust proxy |
fail: no cookie sent | not scanned |
| proxy 8443 | same, with trust proxy |
pass: connect.sid=...; Path=/; HttpOnly; Secure; SameSite=Lax |
not scanned |
| apache 443 | Header edit Set-Cookie (onsuccess) for a proxied app |
pass | not scanned |
| apache 8443 | Header always edit Set-Cookie for the same app |
fail: cookie unchanged | not scanned |
apache 443, /secure-app/ |
app sets Secure but not HttpOnly; the two-line edit |
pass | not scanned |
apache 9443, /secure-app/ |
same app; one-line edit that skips cookies with Secure |
fail: HttpOnly missing | not scanned |
nginx trap 32443 /ok |
SET-COOKIE: sid=1;SECURE;HTTPONLY and tabs around attributes |
pass (valid) | not scanned |
nginx trap 32443 /bad |
value and path contain "secure", attribute missing | fail: Secure missing | not scanned |
| a port that never answers | not tested (exit 2) | not run |
The run was done by Claude Opus 5.5 (agent) on an internal Docker network with no outside access. Expected results were written before each run and are in the lab's results folder, with the raw outputs, image digests and file hashes of run 8. Runs 2 to 8 were checked in four rounds by a separate AI agent; the fourth round compared run 8 with its expected results.
Sources
Primary records first. Record identifiers link from the facts box.
Scanner rules and tool documentation
- ZAP, alert 10010, accessed 2026-11-26
- ZAP, alert 10011, accessed 2026-11-26
- ZAP, alert 10054-1, accessed 2026-11-26
- ZAP, CookieSecureFlagScanRule.java at commit afb5113 (Apache 2.0), accessed 2026-11-26
- PortSwigger, issue 0x00500200, accessed 2026-11-26
- PortSwigger, issue 0x00500600, accessed 2026-11-26
- Tenable, Nessus plugin 85601, accessed 2026-11-26
- Tenable, Nessus plugin 85602, accessed 2026-11-26
Standards and specifications
- IETF, RFC 6265, accessed 2026-11-26
- IETF, draft-ietf-httpbis-rfc6265bis-22, accessed 2026-11-26
Vendor documentation and statements
- Express, res.cookie, accessed 2026-11-26
- express-session README, accessed 2026-11-26
- nginx, proxy_cookie_flags, accessed 2026-11-26
- Apache httpd, mod_headers, accessed 2026-11-26
- Microsoft, HttpCookiesSection, accessed 2026-11-26
- Microsoft, httpCookies element, accessed 2026-11-26
- Netlify, custom headers, accessed 2026-11-26
Our lab
- Our lab, arviser-labs at commit e225f47, scanner-findings, accessed 2026-11-26
- Our test, cookie-flags.sh, accessed 2026-11-26
- Our lab, run 8 of 2026-11-26: raw outputs, image digests and file hashes, accessed 2026-11-26
Corrections
No corrections.
Report an error to contact@arviser.com.
How this page was made: Claude Opus 5.5, an AI model, built and ran the lab and wrote this page from the sources listed. Separate AI agents checked the claims and the lab tests in four rounds. Vadim Nareyko approved the family template and the sample pages on 26 November 2026, from a summary in Russian.
Text and data on this page: CC BY 4.0. Code in our lab: MIT. Quoted third-party material keeps its own terms.