fix(security): set secure: true on auth cookie for production (HTTPS) #86
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Security Issue — MEDIUM
Found in:
frontend/src/routes/login/+page.server.ts(line ~38)The vulnerable pattern
The
secureflag on a cookie tells the browser to only send the cookie over HTTPS connections. Withsecure: false, the browser will happily send theauth_tokencookie over plain HTTP — including on a public Wi-Fi network where an attacker is running a passive sniffer or a man-in-the-middle proxy.Attack: User accesses the app over HTTP (accidentally, via a redirect, or because HTTPS isn't enforced). The
auth_tokencookie is transmitted in cleartext. The attacker captures it and replays it to authenticate as that user.The fix
Derive the value from the environment rather than hardcoding
false:Alternatively, read an explicit env var:
secure: env.COOKIE_SECURE === 'true', and setCOOKIE_SECURE=truein the production.env.Also enforce HTTPS at the infrastructure level (reverse proxy / load balancer) and add an
HSTSheader so browsers never fall back to HTTP once they've seen the site over HTTPS:Why
httpOnlyprevents JavaScript from reading the cookie (XSS protection).sameSite: strictprevents it from being sent in cross-site requests (CSRF protection). But neither helps if the cookie travels over an unencrypted connection —secureis what closes that gap.Priority
MEDIUM — only exploitable over HTTP. As long as the app is HTTP-only on a trusted home network, risk is low. Must be fixed before any internet-facing or untrusted-network deployment.
Audit note (2026-05-07) — scope is sufficient as-is, but a deeper issue is now tracked separately
This issue's scope (
secure: trueon the auth cookie for HTTPS) remains correct and necessary. It is not what the audit calls F-13.The audit found the cookie value itself is
Basic <base64(email:password)>— i.e., reversible plaintext credentials, not a session ID:secure: true(this issue) is necessary but not sufficient — even with HTTPS, an XSS would leak the user's plaintext password (BCrypt-on-the-server is bypassed because the password travels in the cookie). That is a separate, larger refactor.A new P0 issue will be filed separately for the redesign to an opaque session token (Spring Session JDBC is already configured but unused by the frontend). This issue stays focused on flipping the flag for the production HTTPS deploy.
Tracked in audit doc as F-13 (Critical). See
docs/audits/2026-05-07-pre-prod-architectural-review.md.