security(server): store keyed hash of auth token in session cookie - #10691
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
dmadisetti
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.