Skip to content

fix(#1136): replace localStorage with HMAC-signed session cookie (no process memory)#1235

Open
ionfwsrijan wants to merge 1 commit into
utksh1:mainfrom
ionfwsrijan:fix/issue-1136-signed-session-cookie
Open

fix(#1136): replace localStorage with HMAC-signed session cookie (no process memory)#1235
ionfwsrijan wants to merge 1 commit into
utksh1:mainfrom
ionfwsrijan:fix/issue-1136-signed-session-cookie

Conversation

@ionfwsrijan

@ionfwsrijan ionfwsrijan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

The API key was stored in localStorage under secuscan_api_key, making it accessible to any XSS attack.

Solution

Replaced localStorage with HMAC-signed session cookies — no server-side session store needed.

Key differences from previous attempt (PR #1172)

  1. No process-memory session store — cookies are self-contained HMAC-signed tokens. Survives server restarts, works across multiple processes, no external dependencies.
  2. Conditional Secure flag — only set when request is over HTTPS or carries X-Forwarded-Proto: https. HTTP localhost development works without breaking.
  3. No formatting churn in main.py — exactly 2 lines changed (import + router registration).
  4. No new dependencies — uses stdlib , hmac, hashlib, base64, json

Closes #1136

@ionfwsrijan

Copy link
Copy Markdown
Contributor Author

@utksh1 Please review this now

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.

[BUG] API Key Stored in localStorage Enables Credential Theft via XSS

1 participant