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

Closed
opened 2026-03-28 17:21:40 +00:00 by AI-Manager · 0 comments
Owner

Context

Roadmap reference: P1 - Security hardening

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This is a critical security risk in production deployments.

What to do

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

  1. Reads the JWT_SECRET environment variable
  2. Compares it to the known default value sparc-secret-key-change-in-production
  3. If the environment is not development (check via ENVIRONMENT or APP_ENV env var) and the default secret is in use, raises a RuntimeError and refuses to start

Acceptance criteria

  • Application refuses to start in non-dev environments when JWT_SECRET is unset or set to the default value
  • A clear error message is printed explaining which env var to set
  • In development environment, a warning is logged but startup is not blocked
  • Existing tests still pass
## Context Roadmap reference: P1 - Security hardening `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This is a critical security risk in production deployments. ## What to do Add a startup check in `auth.py` (or application startup in `api.py`) that: 1. Reads the `JWT_SECRET` environment variable 2. Compares it to the known default value `sparc-secret-key-change-in-production` 3. If the environment is not `development` (check via `ENVIRONMENT` or `APP_ENV` env var) and the default secret is in use, raises a `RuntimeError` and refuses to start ## Acceptance criteria - [ ] Application refuses to start in non-dev environments when `JWT_SECRET` is unset or set to the default value - [ ] A clear error message is printed explaining which env var to set - [ ] In `development` environment, a warning is logged but startup is not blocked - [ ] Existing tests still pass
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 17:21:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#733