Skip to content

fix(security): replace hardcoded BETTER_AUTH_SECRET with Docker secret support#4374

Merged
Siumauricio merged 2 commits intocanaryfrom
fix/better-auth-secret-hardcoded
May 9, 2026
Merged

fix(security): replace hardcoded BETTER_AUTH_SECRET with Docker secret support#4374
Siumauricio merged 2 commits intocanaryfrom
fix/better-auth-secret-hardcoded

Conversation

@Siumauricio
Copy link
Copy Markdown
Contributor

@Siumauricio Siumauricio commented May 9, 2026

Summary

Addresses GHSA-w3gm-rc4p-9rhj — Pre-Auth Admin Takeover via Hardcoded Authentication Secret.

Related here Dokploy/website@4dd767b

  • Disables /verify-email endpoint in self-hosted via disabledPaths — closes both exploit vectors from the PoC (forged JWT auto-login and change-email-verification session creation)
  • Removes hardcoded BETTER_AUTH_SECRET fallback from constants/index.ts and moves resolution logic to lib/auth-secret.ts, following the same pattern as db/constants.ts
  • Resolution order: BETTER_AUTH_SECRET env var → BETTER_AUTH_SECRET_FILE (Docker secret) → hardcoded legacy with deprecation warning in logs
  • Adds setupAuthSecret() to the server install script — generates a unique dokploy-auth-secret Docker secret on new installations
  • Adds migrate-auth-secret.ts script to re-encrypt existing 2FA TOTP secrets when rotating the auth secret, preventing 2FA breakage during migration
  • Adds pnpm run migrate-auth-secret command for running the migration inside the container

…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.
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 9, 2026
@Siumauricio Siumauricio merged commit 1c6fdc1 into canary May 9, 2026
4 checks passed
@Siumauricio Siumauricio deleted the fix/better-auth-secret-hardcoded branch May 9, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant