Skip to content

Require an explicit Rails secret key in production - #1895

Open
28Hus wants to merge 1 commit into
publiclab:mainfrom
28Hus:fix/production-secret-key-base
Open

28Hus wants to merge 1 commit into
publiclab:mainfrom
28Hus:fix/production-secret-key-base

Conversation

@28Hus

@28Hus 28Hus commented Oct 24, 2026

Copy link
Copy Markdown

Fixes #1894.

Remove the public secret_key_base fallback from the production initializer. Production startup now requires an explicit SECRET_KEY_BASE that is at least 30 characters and rejects the previously published value. Non-production environments continue to use the existing Rails secrets configuration.

The Docker Compose production service now requires SECRET_KEY_BASE instead of silently starting with a shared key. Its error message explains how to generate one with rake secret.

Deployments using the former key must rotate it; existing session cookies will become invalid. No unrelated files or test cases were added.

Validation

  • ruby -c config/initializers/secret_token.rb passed.
  • docker compose config fails when SECRET_KEY_BASE is missing and succeeds when it is supplied.
  • An isolated Ruby check exercised production rejection of missing, blank, short, and former public keys; acceptance and configuration of a valid-length key; and unchanged non-production behavior.
  • The full Rails test suite was not run because the locked Bundler version (2.3.14) is not installed in the local environment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Hardcoded Session Secret Enables User Impersonation

1 participant