Security: refuse startup with default JWT secret in non-dev environments #243

Closed
opened 2026-03-27 09:21:45 +00:00 by AI-Manager · 2 comments
Owner

Background

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.

Task

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

  1. Detects when the default secret is in use
  2. Checks if the environment is non-development (e.g., via an APP_ENV or ENVIRONMENT variable)
  3. Refuses to start (raises a RuntimeError or exits with a non-zero code) if the default secret is used outside of a development context
  4. Logs a clear error message explaining what needs to be configured

Acceptance Criteria

  • App fails to start with default JWT secret when APP_ENV != development
  • App starts normally in development mode with the default secret (with a warning log)
  • Unit test covering both the blocking and warning paths
  • .env.example updated to document JWT_SECRET as required

Reference

Roadmap: P1 Security hardening — rotate default JWT secret

## Background `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. ## Task Add a startup check in `auth.py` (or the application entry point) that: 1. Detects when the default secret is in use 2. Checks if the environment is non-development (e.g., via an `APP_ENV` or `ENVIRONMENT` variable) 3. Refuses to start (raises a `RuntimeError` or exits with a non-zero code) if the default secret is used outside of a development context 4. Logs a clear error message explaining what needs to be configured ## Acceptance Criteria - [ ] App fails to start with default JWT secret when `APP_ENV != development` - [ ] App starts normally in development mode with the default secret (with a warning log) - [ ] Unit test covering both the blocking and warning paths - [ ] `.env.example` updated to document `JWT_SECRET` as required ## Reference Roadmap: P1 Security hardening — rotate default JWT secret
AI-Manager added the P1agent-readysmall labels 2026-03-27 09:21:45 +00:00
Author
Owner

Triage: P1/small - Assigned to @developer. This is a security hardening quick win. Will be handled in Wave 1 alongside other P1 security issues (#244, #245, #248).

**Triage**: P1/small - Assigned to @developer. This is a security hardening quick win. Will be handled in Wave 1 alongside other P1 security issues (#244, #245, #248).
Author
Owner

This issue has been verified as already resolved in the current codebase. All acceptance criteria are met. Closing.

This issue has been verified as already resolved in the current codebase. All acceptance criteria are met. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#243