# Cookie without Secure or HttpOnly flag: is it real, how to fix it, what to tell the customer

By Vadim Nareyko, founder, Arviser. Published 2026-11-28 · Updated 2026-11-28 · Last reviewed 2026-11-28

## 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](https://www.zaproxy.org/docs/alerts/10011/) "Cookie Without Secure Flag" and [10010](https://www.zaproxy.org/docs/alerts/10010/) "Cookie No HttpOnly Flag" (passive, Low); often with ZAP [10054-1](https://www.zaproxy.org/docs/alerts/10054-1/) "Cookie without SameSite Attribute". Burp [0x00500200](https://portswigger.net/kb/issues/00500200_tls-cookie-without-secure-flag-set) "TLS cookie without secure flag set" and [0x00500600](https://portswigger.net/kb/issues/00500600_cookie-without-httponly-flag-set) "Cookie without HttpOnly flag set". Nessus [85602](https://www.tenable.com/plugins/nessus/85602) "Web Application Cookies Not Marked Secure" and [85601](https://www.tenable.com/plugins/nessus/85601) "Web Application Cookies Not Marked HttpOnly"
- Standard: [RFC 6265](https://www.rfc-editor.org/rfc/rfc6265.html) §4.1.2.5 and §4.1.2.6; [draft-ietf-httpbis-rfc6265bis-22](https://datatracker.ietf.org/doc/draft-ietf-httpbis-rfc6265bis/)
- Lab: [scanner-findings](https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/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]`](https://github.com/nareyko/arviser-labs/blob/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/tests/cookie-flags.sh), fails on the vulnerable target, passes after the fix

## 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](https://github.com/zaproxy/zap-extensions/blob/afb5113e389ef1d6ff66e03bbf63d2a0b4e6c088/addOns/pscanrules/src/main/java/org/zaproxy/zap/extension/pscanrules/CookieSecureFlagScanRule.java)). 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?

```sh
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 `Secure` and `HttpOnly`. 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. `HttpOnly` would break it. Keep `Secure`. 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-Cookie` headers 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 no `trust proxy`, our target sent no `Set-Cookie` at all. The login page loaded and the user was never logged in. express-session documents this: behind a proxy with `secure: true`, set `trust proxy` ([express-session](https://github.com/expressjs/session#cookiesecure)). With `app.set('trust proxy', 1)` the cookie came back with `HttpOnly; 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). With `samesite=lax` in that line, nginx also rewrote an upstream `sso` cookie from `SameSite=None` to `SameSite=Lax`. Cross-site sign-in callbacks and embedded widgets that need `None` stop 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](https://www.rfc-editor.org/rfc/rfc6265.html#section-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](https://www.rfc-editor.org/rfc/rfc6265.html#section-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](https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-22.txt)). 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)

```js
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`](https://expressjs.com/en/5x/api/response/)). 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](https://github.com/expressjs/session#cookie)):

```js
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):

```nginx
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`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_flags)):

```nginx
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](https://httpd.apache.org/docs/2.4/mod/mod_headers.html#header)). Our own lines, for a proxied application whose session cookie is named `sid`, one line per flag:

```apache
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](https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.httpcookiessection)). Code that sets a cookie explicitly can override them, and the forms-authentication cookie follows `<forms requireSSL>` rather than `httpCookies` ([httpCookies element](https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms228262(v=vs.100))).

### 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](https://docs.netlify.com/manage/routing/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 <date>.

**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`](https://github.com/nareyko/arviser-labs/blob/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/tests/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 lacks `HttpOnly` unless its name is in the comma-separated list, and also when the URL sets no cookie at all, since then nothing was tested. With `SAMESITE_NONE=name1,name2` set, it also fails when one of those cookies has any SameSite value other than `None`, 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 `-k` for a real site, then `sh 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`, `tr` and `head`, 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 `HttpOnly` really needs to be readable; whether the SameSite value is right for cookies you did not put in `SAMESITE_NONE`; `Domain` scope 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](https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/results/2026-11-26), with the raw outputs, image digests and file hashes of [run 8](https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/results/2026-11-26/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.

## Related pages

- [HSTS missing (Strict-Transport-Security header not set): is it real, how to fix it, what to tell the customer](/library/findings/hsts-missing)
- [ZAP alert 10098, Cross-Domain Misconfiguration: is it real, how to fix it, what to tell the customer](/library/findings/zap-10098-cross-domain-misconfiguration)
- [Missing anti-clickjacking header (X-Frame-Options): is it real, how to fix it, what to tell the customer](/library/findings/missing-anti-clickjacking-header)

## Sources

- ZAP, alert 10010: https://www.zaproxy.org/docs/alerts/10010/ (accessed 2026-11-26)
- ZAP, alert 10011: https://www.zaproxy.org/docs/alerts/10011/ (accessed 2026-11-26)
- ZAP, alert 10054-1: https://www.zaproxy.org/docs/alerts/10054-1/ (accessed 2026-11-26)
- ZAP, CookieSecureFlagScanRule.java at commit afb5113 (Apache 2.0): https://github.com/zaproxy/zap-extensions/blob/afb5113e389ef1d6ff66e03bbf63d2a0b4e6c088/addOns/pscanrules/src/main/java/org/zaproxy/zap/extension/pscanrules/CookieSecureFlagScanRule.java (accessed 2026-11-26)
- PortSwigger, issue 0x00500200: https://portswigger.net/kb/issues/00500200_tls-cookie-without-secure-flag-set (accessed 2026-11-26)
- PortSwigger, issue 0x00500600: https://portswigger.net/kb/issues/00500600_cookie-without-httponly-flag-set (accessed 2026-11-26)
- Tenable, Nessus plugin 85601: https://www.tenable.com/plugins/nessus/85601 (accessed 2026-11-26)
- Tenable, Nessus plugin 85602: https://www.tenable.com/plugins/nessus/85602 (accessed 2026-11-26)
- IETF, RFC 6265: https://www.rfc-editor.org/rfc/rfc6265.html (accessed 2026-11-26)
- IETF, draft-ietf-httpbis-rfc6265bis-22: https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-22.txt (accessed 2026-11-26)
- Express, res.cookie: https://expressjs.com/en/5x/api/response/ (accessed 2026-11-26)
- express-session README: https://github.com/expressjs/session (accessed 2026-11-26)
- nginx, proxy_cookie_flags: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_flags (accessed 2026-11-26)
- Apache httpd, mod_headers: https://httpd.apache.org/docs/2.4/mod/mod_headers.html (accessed 2026-11-26)
- Microsoft, HttpCookiesSection: https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.httpcookiessection (accessed 2026-11-26)
- Microsoft, httpCookies element: https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms228262(v=vs.100) (accessed 2026-11-26)
- Netlify, custom headers: https://docs.netlify.com/manage/routing/headers/ (accessed 2026-11-26)
- Our lab, arviser-labs at commit e225f47, scanner-findings: https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings (accessed 2026-11-26)
- Our test, cookie-flags.sh: https://github.com/nareyko/arviser-labs/blob/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/tests/cookie-flags.sh (accessed 2026-11-26)
- Our lab, run 8 of 2026-11-26: raw outputs, image digests and file hashes: https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings/results/2026-11-26/run-8 (accessed 2026-11-26)

## Corrections

No corrections.

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](https://creativecommons.org/licenses/by/4.0/). Code in [our lab](https://github.com/nareyko/arviser-labs/tree/e225f47fc1f1ab3f5755419c419dada190c7c53d/scanner-findings): [MIT](https://opensource.org/license/mit). Quoted third-party material keeps its own terms.
