Security [HIGH]: Session/Cookie hardening — Secure flag, concurrent-session enforcement, JTI exposure #41
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?
Problem
Three issues: (1) Cookie Secure flag tied to
NODE_ENV === 'production'— staging over HTTPS but NODE_ENV≠production ships cookies without Secure. (2) Concurrent-session enforcement in jwt() catches DB errors and logs them but doesn't block login → unlimited sessions during DB degradation. (3) Session JTI exposed to client in useSession() — internal identifier leaks.Evidence
apps/web/src/server/auth.config.ts:16-44 — secure: NODE_ENV === 'production'apps/web/src/server/auth.ts:278-281 — concurrent-session try/catch non-blockingapps/web/src/server/auth.ts:230-232 — session.user.jti assigned client-visibleImpact
(1) MITM-vulnerable sessions on staging. (2) Concurrent-session limit bypassable via DB-load attack. (3) JTI exposure enables social-engineering or targeted invalidation attacks.
Proposed Fix
(1)
secure: truewhen resolved AUTH_URL uses https, independent of NODE_ENV. Use__Host-prefix. (2) Block login (throw) when session-registry write fails. (3) Removesession.user.jtiassignment (keep only in JWT).Acceptance Criteria
session.userpayloadParent Epic: #1
Source: Full-Codebase Security Audit 2026-04-16 (A-10, A-11, A-12)
Resolved in commit
d45cc00(security: cookie + session hardening). Secure flag enforced in prod, concurrent-session cap implemented, JTI no longer surfaced in responses.