Refuse to start with default JWT secret in non-development environments #1350

Closed
opened 2026-03-30 15:21:48 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security hardening

auth.py ships a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is unset. This is a serious security risk in production deployments.

What to do

  • Add a startup check in auth.py (or the application entrypoint) that detects when the default secret is in use.
  • If the environment is not development (check via APP_ENV or similar env var), raise a fatal error and refuse to start.
  • Log a clear error message explaining how to set JWT_SECRET.

Acceptance criteria

  • Starting the app without JWT_SECRET set in a non-dev environment exits with a non-zero code and a descriptive error message.
  • Starting the app in development mode without JWT_SECRET set logs a warning but proceeds.
  • Existing tests pass; add a test asserting the startup check behavior.
## Context Roadmap item: P1 Security hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is unset. This is a serious security risk in production deployments. ## What to do - Add a startup check in `auth.py` (or the application entrypoint) that detects when the default secret is in use. - If the environment is not `development` (check via `APP_ENV` or similar env var), raise a fatal error and refuse to start. - Log a clear error message explaining how to set `JWT_SECRET`. ## Acceptance criteria - Starting the app without `JWT_SECRET` set in a non-dev environment exits with a non-zero code and a descriptive error message. - Starting the app in `development` mode without `JWT_SECRET` set logs a warning but proceeds. - Existing tests pass; add a test asserting the startup check behavior.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 15:21:48 +00:00
Author
Owner

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1350