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

Closed
opened 2026-03-29 04:21:22 +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.

Work to do

  1. In auth.py (or startup logic), add a check that reads the JWT_SECRET environment variable.
  2. If JWT_SECRET equals the default fallback value AND the environment is not development (e.g., APP_ENV != "development"), raise a fatal error and refuse to start.
  3. Log a clear error message explaining how to set a proper secret.
  4. Add or update relevant unit tests to verify the startup guard works.

Acceptance criteria

  • Starting the API with JWT_SECRET unset or set to the default value in a non-development environment raises a startup error.
  • Starting with a custom secret succeeds normally.
  • Starting in APP_ENV=development with the default secret logs a warning but does not block startup.
  • 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 is a serious security risk in production deployments. ## Work to do 1. In `auth.py` (or startup logic), add a check that reads the `JWT_SECRET` environment variable. 2. If `JWT_SECRET` equals the default fallback value AND the environment is not development (e.g., `APP_ENV != "development"`), raise a fatal error and refuse to start. 3. Log a clear error message explaining how to set a proper secret. 4. Add or update relevant unit tests to verify the startup guard works. ## Acceptance criteria - Starting the API with `JWT_SECRET` unset or set to the default value in a non-development environment raises a startup error. - Starting with a custom secret succeeds normally. - Starting in `APP_ENV=development` with the default secret logs a warning but does not block startup. - Existing tests continue to pass.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 04:21:22 +00:00
Author
Owner

Resolved in codebase. check_jwt_secret() in SPARC/auth.py already refuses to start with the default JWT secret when APP_ENV is not development. Closing as implemented.

Resolved in codebase. check_jwt_secret() in SPARC/auth.py already refuses to start with the default JWT secret when APP_ENV is not development. 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#849