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

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

Background

auth.py ships a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is unset. This is a critical security gap — any deployment that forgets to set the env var will silently use a well-known secret.

Task

Add a startup check in auth.py (or the application entrypoint) that:

  1. Detects when JWT_SECRET is equal to the default fallback value.
  2. Checks the runtime environment (e.g. ENVIRONMENT != "development").
  3. Raises a fatal error and refuses to start if the default secret is detected outside development.

Acceptance Criteria

  • Application fails fast with a clear error message if started with the default JWT secret and ENVIRONMENT is not development.
  • Application starts normally in development mode with the default secret (no breakage for local dev).
  • Existing tests pass and a new test covers the startup check.

Reference

Roadmap: P1 Security hardening — Rotate default JWT secret.

## Background `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is unset. This is a critical security gap — any deployment that forgets to set the env var will silently use a well-known secret. ## Task Add a startup check in `auth.py` (or the application entrypoint) that: 1. Detects when `JWT_SECRET` is equal to the default fallback value. 2. Checks the runtime environment (e.g. `ENVIRONMENT != "development"`). 3. Raises a fatal error and refuses to start if the default secret is detected outside development. ## Acceptance Criteria - [ ] Application fails fast with a clear error message if started with the default JWT secret and `ENVIRONMENT` is not `development`. - [ ] Application starts normally in development mode with the default secret (no breakage for local dev). - [ ] Existing tests pass and a new test covers the startup check. ## Reference Roadmap: P1 Security hardening — Rotate default JWT secret.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 09:21:31 +00:00
Author
Owner

Triaged by repo manager. This issue has already been resolved in the current codebase. auth.py contains check_jwt_secret() (lines 23-33) which raises RuntimeError if JWT_SECRET equals the default value and APP_ENV != 'development'. The APP_ENV variable is defined in config.py (line 54) and documented in .env.example. Closing as already implemented.

Triaged by repo manager. This issue has already been resolved in the current codebase. `auth.py` contains `check_jwt_secret()` (lines 23-33) which raises `RuntimeError` if `JWT_SECRET` equals the default value and `APP_ENV != 'development'`. The `APP_ENV` variable is defined in `config.py` (line 54) and documented in `.env.example`. Closing as already implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#940