Skip to content

security(server): store keyed hash of auth token in session cookie - #10691

Merged
dmadisetti merged 1 commit into
mainfrom
ms/signed-cookied
Sep 1, 2026
Merged

security(server): store keyed hash of auth token in session cookie#10691
dmadisetti merged 1 commit into
mainfrom
ms/signed-cookied

Conversation

@mscolnick

@mscolnick mscolnick commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

The session cookie is signed by starlette (tamper-proof) but not
encrypted, so anyone holding the cookie could base64-decode it and read
the raw auth token. Store HMAC-SHA256(secret, token) instead, so a
leaked cookie no longer leaks the token or can be replayed as a bearer
token / ?access_token= query param.

The secret is still random per server process, but can now be pinned
via MARIMO_SESSION_SECRET so sessions survive restarts or are shared
across replicas. No new dependencies; stdlib hmac/hashlib only.

Technically, the cookie is exactly as sensitive as the token itself so this does not add added protection when auth tokens are randomly generated, but in case any downstream user's use the same token each time, this can be another layer of defense in depth.

The session cookie is signed by starlette (tamper-proof) but not
encrypted, so anyone holding the cookie could base64-decode it and read
the raw auth token. Store HMAC-SHA256(secret, token) instead, so a
leaked cookie no longer leaks the token or can be replayed as a bearer
token / ?access_token= query param.

The secret is still random per server process, but can now be pinned
via MARIMO_SESSION_SECRET so sessions survive restarts or are shared
across replicas. No new dependencies; stdlib hmac/hashlib only.
Copilot AI lite review requested due to automatic review settings August 28, 2026 15:10
@mscolnick
mscolnick requested a review from akshayka as a code owner August 28, 2026 15:10
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 28, 2026 3:11pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dmadisetti
dmadisetti merged commit 32efbee into main Sep 1, 2026
43 of 45 checks passed
@dmadisetti
dmadisetti deleted the ms/signed-cookied branch September 1, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants