Skip to content

fix : validate SECRET_KEY is set and long enough at startup #1477

Description

@tmdeveloper007

Summary of What Needs to be Done:
The SECRET_KEY setting in backend/app/core/config.py accepts empty strings without raising a validation error. If the .env file contains SECRET_KEY= (empty value), pydantic-settings silently accepts it and the app starts with an insecure key, allowing trivial JWT forgery.

Changes that Need to be Made:

  • backend/app/core/config.py: Add a pydantic @field_validator on SECRET_KEY that raises ValueError if the value is empty or shorter than 32 characters. Provide a clear error message: generate one with: openssl rand -hex 32

Impact that it would Provide:

  • Fails fast and loudly if SECRET_KEY is misconfigured
  • Prevents silent insecurity in production deployments
  • Aligns with the principle of secure defaults

Note: Please assign this issue to the tmdeveloper007 account.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions