Add startup check to reject default JWT secret in non-dev environments #1068

Closed
opened 2026-03-29 20:21:51 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap reference: P1 / Security hardening

auth.py ships a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is unset. This means the app can silently start in production with a well-known, guessable secret.

What to do

  • In auth.py (or application startup), read JWT_SECRET from the environment.
  • Detect whether the app is running in a non-development environment (e.g., APP_ENV != "development" or DEBUG != "true").
  • If the secret equals the known default value AND the environment is not development, raise a fatal error and refuse to start.
  • Log a clear error message explaining why startup was aborted.

Acceptance criteria

  • App refuses to start in production mode when JWT_SECRET is unset or equals the default value.
  • App starts normally in development mode with the default secret (with a warning log).
  • Unit test covers both the rejection and the warning-only paths.
  • README or .env.example documents the JWT_SECRET requirement.
## Context Roadmap reference: P1 / Security hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is unset. This means the app can silently start in production with a well-known, guessable secret. ## What to do - In `auth.py` (or application startup), read `JWT_SECRET` from the environment. - Detect whether the app is running in a non-development environment (e.g., `APP_ENV != "development"` or `DEBUG != "true"`). - If the secret equals the known default value AND the environment is not development, raise a fatal error and refuse to start. - Log a clear error message explaining why startup was aborted. ## Acceptance criteria - [ ] App refuses to start in production mode when `JWT_SECRET` is unset or equals the default value. - [ ] App starts normally in development mode with the default secret (with a warning log). - [ ] Unit test covers both the rejection and the warning-only paths. - [ ] `README` or `.env.example` documents the `JWT_SECRET` requirement.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 20:21:51 +00:00
Author
Owner

This issue was resolved by PR #27 (commit 47cddcb) which added a JWT startup guard that rejects the default secret in non-dev environments. Closing as complete.

This issue was resolved by PR #27 (commit 47cddcb) which added a JWT startup guard that rejects the default secret in non-dev environments. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1068