Skip to content

fix(rules): cookie-flags reports CSRF token cookies as info, not an HttpOnly warning #1378 - #1390

Closed
nc9 wants to merge 2 commits into
mainfrom
fix/csrf-cookies-httponly-1378
Closed

nc9 wants to merge 2 commits into
mainfrom
fix/csrf-cookies-httponly-1378

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1378 (the Lovable __dpl part shipped in v0.0.146).

Some frameworks send a CSRF token in a cookie that the frontend reads from script (Angular and Axios do); HttpOnly is needed only when the frontend does not read it.

  • Two entries join the one list, packages/rules/src/security/platform-cookies.ts, each with a kind (platform or csrf), docs links and the evidence. Every claim is cited from the framework docs, which I fetched: Angular (HttpClient reads XSRF-TOKEN, sets X-XSRF-TOKEN), Laravel (the XSRF-TOKEN cookie is sent so Angular and Axios can set the header), Spring Security (CookieCsrfTokenRepository writes XSRF-TOKEN; HttpOnly false so JavaScript frameworks can read it) and Django (csrftoken is the default name; CSRF_COOKIE_HTTPONLY defaults to False and Django says setting it offers no practical protection).
  • A listed CSRF cookie without HttpOnly gives an info check cookie-httponly-csrf naming the frameworks, the reason and the docs. Only the missing-HttpOnly warning is lifted: Secure, SameSite and SameSite=None are checked as before.
  • Exact-name matching only (documented): session, sid, csrf_session, XSRF-TOKEN2, CSRFTOKEN and xsrf-token still warn.
  • Not added: other double-submit names and preference cookies, because I found no source documenting them. Follow-up issue to file if you want them.

Tests (packages/rules/tests/cookie-flags.test.ts, 5 new, plus the newline-joined test updated because it used csrftoken as its example of a warned cookie). Gates: rules tests (cookie-flags, private-target-skip), tsgo in packages/rules, make validate, released-changelog guard. Docs: docs/rules/security/cookie-flags.mdx. CHANGELOG under Unreleased / Fixed. Skill: no change needed.

nik

Review round: wording now claims only what the sources say (Django supports HttpOnly on its cookie and calls it no practical protection; Spring recommends HttpOnly when JavaScript does not need the cookie; Laravel calls the cookie a convenience for Angular and Axios), corpus counts dropped from the public text, names stated case-sensitive, message without a trailing paren, tests for prefixed names and a CSRF-only page, glossary page updated.

…token) as info, not an HttpOnly warning #1378

Signed-off-by: Nik Cubrilovic <[email protected]>
…s say; case-sensitive names; glossary #1378

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 mentioned this pull request Oct 31, 2026
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.147 as f03f2ee7 796d83ed via #1412. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.147. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant