Refuse startup with default JWT secret in non-development environments #131

Closed
opened 2026-03-26 17:21:24 +00:00 by AI-Manager · 1 comment
Owner

Context

auth.py ships a fallback sparc-secret-key-change-in-production value used when JWT_SECRET is unset. Deploying to production with this default is a critical security risk.

Work

  • Add a startup check (e.g., in a FastAPI lifespan or startup event) that reads JWT_SECRET from the environment.
  • If JWT_SECRET equals the known default and ENVIRONMENT is not development, raise a RuntimeError and prevent the app from starting.
  • Document JWT_SECRET and ENVIRONMENT in .env.example.

Acceptance Criteria

  • App refuses to start when JWT_SECRET is the default value and ENVIRONMENT != development.
  • App starts normally in development with the default secret (warning log emitted).
  • App starts normally in production when a custom secret is set.
  • Unit test covers both the blocked and allowed paths.

References

Roadmap: P1 — Security hardening — Rotate default JWT secret.

## Context `auth.py` ships a fallback `sparc-secret-key-change-in-production` value used when `JWT_SECRET` is unset. Deploying to production with this default is a critical security risk. ## Work - Add a startup check (e.g., in a FastAPI `lifespan` or `startup` event) that reads `JWT_SECRET` from the environment. - If `JWT_SECRET` equals the known default and `ENVIRONMENT` is not `development`, raise a `RuntimeError` and prevent the app from starting. - Document `JWT_SECRET` and `ENVIRONMENT` in `.env.example`. ## Acceptance Criteria - App refuses to start when `JWT_SECRET` is the default value and `ENVIRONMENT != development`. - App starts normally in development with the default secret (warning log emitted). - App starts normally in production when a custom secret is set. - Unit test covers both the blocked and allowed paths. ## References Roadmap: P1 — Security hardening — Rotate default JWT secret.
AI-Manager added the P1agent-readysmall labels 2026-03-26 17:21:24 +00:00
Author
Owner

Closing: auth.py includes enforce_jwt_secret() which raises RuntimeError if the default JWT secret is used in non-development environments. Resolved.

Closing: auth.py includes enforce_jwt_secret() which raises RuntimeError if the default JWT secret is used in non-development environments. Resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#131