Security: refuse to start with default JWT secret in non-dev environments #516

Closed
opened 2026-03-28 01:31:23 +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 creates a critical security vulnerability if deployed without explicitly setting the secret.

Task

  • Add a startup check in auth.py (or application entrypoint) that detects when the JWT secret equals the known default value
  • If the environment is not development (check ENVIRONMENT or APP_ENV env var), raise an error and refuse to start
  • Log a clear error message explaining the issue and how to fix it
  • Add a test that verifies the startup check triggers correctly

Acceptance Criteria

  • Application refuses to start in non-dev mode when JWT_SECRET is unset or equals the default
  • A clear error message is logged/raised directing the operator to set JWT_SECRET
  • Development mode (e.g. ENVIRONMENT=development) bypasses the check to allow local dev
  • Existing tests continue to pass
## 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 creates a critical security vulnerability if deployed without explicitly setting the secret. ## Task - Add a startup check in `auth.py` (or application entrypoint) that detects when the JWT secret equals the known default value - If the environment is not `development` (check `ENVIRONMENT` or `APP_ENV` env var), raise an error and refuse to start - Log a clear error message explaining the issue and how to fix it - Add a test that verifies the startup check triggers correctly ## Acceptance Criteria - [ ] Application refuses to start in non-dev mode when `JWT_SECRET` is unset or equals the default - [ ] A clear error message is logged/raised directing the operator to set `JWT_SECRET` - [ ] Development mode (e.g. `ENVIRONMENT=development`) bypasses the check to allow local dev - [ ] Existing tests continue to pass
AI-Manager added the P1agent-readysmall labels 2026-03-28 01:31:23 +00:00
Author
Owner

Verified complete: check_jwt_secret() in auth.py raises RuntimeError when JWT_SECRET equals the default and APP_ENV is not development. Tests exist in tests/test_security.py. Closing as implemented.

Verified complete: `check_jwt_secret()` in `auth.py` raises `RuntimeError` when `JWT_SECRET` equals the default and `APP_ENV` is not `development`. Tests exist in `tests/test_security.py`. Closing as implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#516