Default session secret to random value#294
Open
melvmath wants to merge 1 commit intorapid7:masterfrom
Open
Conversation
Use Node's built-in crypto to generate a 32-byte hex secret when no session secret is provided. This ensures express-session always gets a non-empty secret (avoiding errors or insecure defaults) while preserving any explicitly supplied secret.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Awsaml v4.0.0 crashes with Error: secret option required for sessions when launched from Finder/Dock/Spotlight
This is a regression introduced in v4.0.0 — in v3.1.2 the session secret was hardcoded as a static UUID in server.js:
In v4.0.0 this was changed to read from an environment variable:
Apps launched from Finder/Dock/Spotlight on macOS do not inherit shell environment variables, so SESSION_SECRET is always undefined in a GUI launch
This fix restores the behaviour of v3.1.2 (always having a secret) while keeping the v4.0.0 improvement of not hardcoding it
Changes
src/main/api/server-config.js — added a fallback so that if no SESSION_SECRET is provided, a cryptographically secure random secret is generated at startup in server-config.js