Cookie flags: Secure, HttpOnly and SameSite on Set-Cookie
SameSite=None without Secure is rejected outright, and a session cookie without HttpOnly is readable by any script. squirrel parses every Set-Cookie.
What the cookie flags are
Set-Cookie carries attributes that decide where a cookie may travel and who may read it. Secure stops the cookie being sent over plain HTTP. HttpOnly stops client-side JavaScript reading it, which closes the usual path from a cross-site scripting bug to a stolen session. SameSite decides whether the cookie rides along on requests started by other sites.
Browsers now default an absent SameSite to Lax, so omitting it is weaker documentation rather than an open door. SameSite=None is the exception: it re-enables cross-site sending for cases like an embedded widget, and browsers reject the cookie entirely unless Secure is set alongside it.
What squirrel checks
The rule reads the set-cookie response header of each crawled page, splits it into individual cookies, and emits these checks:
cookie-flagspasses when the page sets no cookies at all. Message:No cookies set on this page.cookie-samesite-none-insecurefails when a cookie declaresSameSite=NonewithoutSecure. Message:1 cookie(s) set SameSite=None without Secure — modern browsers reject this combination, with the cookie names listed.cookie-securewarns when a cookie on an HTTPS page has noSecureattribute. Message:2 cookie(s) missing the Secure flag. The check is skipped on HTTP pages, where there is no secure connection to pin the cookie to.cookie-httponlywarns when a cookie has noHttpOnlyattribute. Message:2 cookie(s) missing the HttpOnly flag.cookie-httponlyfails, instead of warning, when a session-like cookie has noHttpOnlyattribute and the page loads scripts from another registrable domain. It names up to five of those script hosts and counts the rest. Message:1 session-like cookie(s) missing the HttpOnly flag on a page that loads scripts from 2 third-party host(s): cdn.optimizely.com, www.googletagmanager.com. Any script on the page can read these cookies. See Third-party scripts on the page.cookie-httponly-platformreports info for a cookie withoutHttpOnlythat a hosting platform’s sites commonly carry, naming the platform. Message:1 cookie(s) without HttpOnly that Lovable-hosted sites commonly carry (__dpl); the platform does not document it, so it is reported as info, not a warning.cookie-httponly-csrfreports info for a CSRF token cookie withoutHttpOnly(XSRF-TOKEN,csrftoken), naming the frameworks and linking their docs. Message:1 CSRF token cookie(s) without HttpOnly (csrftoken: Django). Frameworks that read the token from script (Angular, Axios) need it readable; if your frontend does not read it, you can set HttpOnly. Reported as info, not a warning. Docs: https://docs.djangoproject.com/....cookie-samesitereports info when a cookie declares noSameSite, or declares it with an empty value such asSameSite=. Message:2 cookie(s) don't explicitly declare SameSite (browsers default to Lax).cookie-flagspasses when cookies were set and none of the above fired. Message:3 cookie(s) set with Secure, HttpOnly, and SameSite configured correctly.
Cookies exempt from the HttpOnly check
Two kinds of cookie are exempt. A few cookies appear on every site a hosting platform serves: you didn’t set them, you can’t change their flags, and nothing session-like is in them, so a missing HttpOnly on one is not a cookie-theft risk and reports as info instead of a warning. The list is short and kept on evidence, not on platform documentation (the platforms do not always document their cookies):
| Cookie | Platform | Why it is listed |
|---|---|---|
__dpl | Lovable | Present on 1,013 of 1,066 Lovable-hosted sites in a 35,000-audit batch, the only cookie missing HttpOnly. Lovable does not document it. |
A CSRF token cookie is the other exemption. Some frameworks put the token in a cookie so the page’s own script can read it and send it back in a request header (Angular and Axios do). HttpOnly is needed only when your frontend does not read the cookie, and then you can set it; the docs below differ on how much that matters. So a missing HttpOnly on one of these names is reported as info. Only the missing-HttpOnly warning is lifted; Secure and SameSite are still checked.
| Cookie | Framework | Source |
|---|---|---|
XSRF-TOKEN | Angular, Laravel, Spring Security | Angular: HttpClient reads it and sets X-XSRF-TOKEN. Laravel: sent so Angular and Axios can place it in X-XSRF-TOKEN. Spring: CookieCsrfTokenRepository writes it, with HttpOnly false so JavaScript frameworks can read it. |
csrftoken | Django | Django: the default cookie name; CSRF_COOKIE_HTTPONLY defaults to False and Django says setting it offers no practical protection. |
Exemption is by exact cookie name only, and names are case-sensitive as RFC 6265 says (CSRFTOKEN, xsrf-token and __Host-XSRF-TOKEN still warn), on any site: a site that names its own session cookie __dpl would also be exempt. Every other cookie, whatever its name or value, still gets the cookie-httponly warning. Secure and SameSite are checked on these cookies as on any other.
Third-party scripts on the page
HttpOnly matters more on a page that runs other parties’ code. A script on the page can read every cookie that lacks HttpOnly through document.cookie, and that includes each analytics tag, A/B testing snippet and widget the page loads. When one of those scripts changes, whoever controls it can read the cookie too, without any bug in your own code.
So the rule looks at the page’s <script src> elements. A script served from another registrable domain than the page counts as third-party: cdn.optimizely.com on www.example.com does, cdn.example.com does not. Scripts inside <noscript> and blocks that are not JavaScript, such as type="application/json", are skipped. When at least one third-party script is present, a session-like cookie without HttpOnly is reported by cookie-httponly as a failure instead of a warning, one severity step higher. The check lists up to five script hosts in its message and in details.thirdPartyScriptHosts, with the total in details.thirdPartyScriptHostCount. It does not say that any of those scripts does anything wrong; it says that any of them can read the value.
A cookie counts as session-like when its name is a common default session name (PHPSESSID, JSESSIONID, ASP.NET_SessionId, connect.sid, sessionid, sid, or a name ending in _session or .sid such as laravel_session), or when it names a credential the way security/token-storage recognises a key (auth_token, access_token, jwt, session_id). A __Host- or __Secure- prefix is ignored. Other cookies without HttpOnly, such as theme, keep the cookie-httponly warning. The exempt platform and CSRF cookies above stay info.
There is one check, cookie-httponly, with two severities. A session-like cookie without HttpOnly on a page that loads third-party scripts fails, and the message names the scripts’ hosts. Every other cookie without HttpOnly warns. The finding is identified by the cookie name in both cases, so a cookie that moves from a warning to a failure (a third-party script is added to the page) is the same finding getting worse and keeps its first-seen date, and a cookie that is fixed resolves.
A page with no third-party script reports exactly as before. So does a page the crawl could not parse, because its markup is unknown. Only scripts in the page’s markup are seen: a script that another script adds while the page runs is not counted, so a page can run more third-party code than the check names.
Multiple cookies in one header value are split on newlines and on commas that are followed by a name= pair, so an Expires date containing a comma does not split a cookie in two. Only cookies your server sets in a response header are seen; cookies written by JavaScript are not.
How to fix it
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
Set the flags where the cookie is created, in the session middleware or the framework’s cookie helper. A cookie-httponly failure on a page with third-party scripts is fixed the same way, by setting HttpOnly on the cookies it lists; removing third-party scripts also clears it, but the flag is the fix. Drop HttpOnly only for a cookie your own frontend genuinely reads, such as a CSRF token mirrored into the DOM. When you need SameSite=None, add Secure in the same change.
Only cookies your server sets in a Set-Cookie response header are inspected. A cookie written by JavaScript, whether yours or a third party’s, never reaches this rule.
| Rule ID | security/cookie-flags |
| Category | Security |
| Scope | Per-page |
| Severity | warning |
| Weight | 5/10 |
Enable / disable
Disable this rule
[rules]
disable = ["security/cookie-flags"]Disable all Security rules
[rules]
disable = ["security/*"]Enable only this rule
[rules]
enable = ["security/cookie-flags"]enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.
Check names by outcome
Each check name this rule can emit, by what it means to a tool comparing two audits. A problem check is a finding. A clean check says the rule ran over what it covers and found nothing; it clears the problem checks listed beside it, so a finding is fixed when the rule ran over the same scope and a clean check took its place. A not checked check says the rule did not evaluate, and never clears a finding.
| Check name | Outcome | Clears |
|---|---|---|
cookie-samesite-none-insecure | Problem | |
cookie-secure | Problem | |
cookie-httponly-platform | Problem | |
cookie-httponly-csrf | Problem | |
cookie-httponly | Problem | |
cookie-samesite | Problem | |
cookie-flags | Clean | cookie-samesite-none-insecure, cookie-secure, cookie-httponly-platform, cookie-httponly-csrf, cookie-httponly, cookie-samesite |
Related rules
- security/third-party-cookies: cookies set by domains other than yours.
- legal/cookie-consent: whether a cookie consent mechanism is present.
- security/https: the precondition for
Secureto mean anything. - security/csp: the policy that limits the injected script
HttpOnlyprotects against.
Security findings ship in every audit next to the SEO, performance and agent experience rules. See Website security scan with AI for how an agent works through a report.
Glossary: Cookie attributes.
References
Check your site
Run squirrel audit https://nutshop.squirrelscan.com and open the Security section of the report. Every cookie missing a flag is listed by name and page. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.