fix(security): replace hardcoded BETTER_AUTH_SECRET with Docker secret support#4374
Merged
Siumauricio merged 2 commits intocanaryfrom May 9, 2026
Merged
fix(security): replace hardcoded BETTER_AUTH_SECRET with Docker secret support#4374Siumauricio merged 2 commits intocanaryfrom
Siumauricio merged 2 commits intocanaryfrom
Conversation
…ecret handling - Added a new script `migrate-auth-secret.ts` to facilitate the migration of 2FA secrets when changing the BETTER_AUTH_SECRET. - Updated `package.json` to include a command for running the migration script. - Refactored the handling of BETTER_AUTH_SECRET to improve security by removing the hardcoded default and introducing a fallback mechanism using environment variables or Docker secrets. - Updated the authentication logic to utilize the new `betterAuthSecret` function for retrieving the secret.
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.
Summary
Addresses GHSA-w3gm-rc4p-9rhj — Pre-Auth Admin Takeover via Hardcoded Authentication Secret.
Related here Dokploy/website@4dd767b
/verify-emailendpoint in self-hosted viadisabledPaths— closes both exploit vectors from the PoC (forged JWT auto-login and change-email-verification session creation)BETTER_AUTH_SECRETfallback fromconstants/index.tsand moves resolution logic tolib/auth-secret.ts, following the same pattern asdb/constants.tsBETTER_AUTH_SECRETenv var →BETTER_AUTH_SECRET_FILE(Docker secret) → hardcoded legacy with deprecation warning in logssetupAuthSecret()to the server install script — generates a uniquedokploy-auth-secretDocker secret on new installationsmigrate-auth-secret.tsscript to re-encrypt existing 2FA TOTP secrets when rotating the auth secret, preventing 2FA breakage during migrationpnpm run migrate-auth-secretcommand for running the migration inside the container