Arviser

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:

Two traps we reproduced:

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 sid is now set with Secure, HttpOnly and SameSite=Lax. Attached is the Set-Cookie header after login, captured on .

Partly accepted:

sid (the session) now has Secure and HttpOnly. XSRF-TOKEN is read by our front end and copied into a request header as CSRF protection, so it cannot be HttpOnly. It carries Secure and SameSite=Lax, holds no session data, and the server checks it against the session. theme stores 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.

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

Standards and specifications

Vendor documentation and statements

Our lab

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.

Send written scope or question (Free)