[M-2] Session auth weaknesses: no renew_session on login, cookie not secure/encrypted, GET logout, no TTL #14

Closed
opened 2026-11-14 18:28:46 +01:00 by amiryahaya · 1 comment
Owner

Finding

Login sets session_auth without renewing the session; the cookie store is signed but not encrypted and lacks secure: true; logout is a GET (CSRF-able via ); there is no idle/absolute timeout.

Evidence

  • lib/mdid_ws_web/controllers/page_controller.ex:40-43, 75-79
  • lib/mdid_ws_web/endpoint.ex:7-12 — @session_options without secure/encryption_salt

Impact

Session-fixation hygiene gap, cookie sent over plain HTTP if ever reachable non-TLS, forced logouts, indefinitely valid sessions.

Fix

  • renew_session(conn) before put_session on login
  • Add secure: true (and consider :encryption_salt)
  • Make logout POST with CSRF token
  • Add a session_auth_at timestamp with TTL checked in RequireSessionAuth

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding Login sets `session_auth` without renewing the session; the cookie store is signed but not encrypted and lacks `secure: true`; logout is a GET (CSRF-able via <img src="/logout">); there is no idle/absolute timeout. ## Evidence - `lib/mdid_ws_web/controllers/page_controller.ex:40-43, 75-79` - `lib/mdid_ws_web/endpoint.ex:7-12` — `@session_options` without secure/encryption_salt ## Impact Session-fixation hygiene gap, cookie sent over plain HTTP if ever reachable non-TLS, forced logouts, indefinitely valid sessions. ## Fix - [ ] `renew_session(conn)` before put_session on login - [ ] Add `secure: true` (and consider `:encryption_salt`) - [ ] Make logout POST with CSRF token - [ ] Add a `session_auth_at` timestamp with TTL checked in RequireSessionAuth _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Author
Owner

Verified fixed on main (1b6216b): renew on login, secure+encrypted cookie, POST /logout, session_auth_at TTL (A-batch).

Verified fixed on main (1b6216b): renew on login, secure+encrypted cookie, POST /logout, session_auth_at TTL (A-batch).
Sign in to join this conversation.
No description provided.