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

Closed
opened 2026-04-20 08:26:26 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 - Security hardening

auth.py ships with a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is not set. Running with this default in production is a critical security risk.

What to do

  1. Add a startup check in auth.py (or config.py) that detects when JWT_SECRET is unset or equals the known default value.
  2. If running in a non-development environment (e.g., ENVIRONMENT != "development" or DEBUG != "true"), raise a fatal error and refuse to start.
  3. Log a clear error message indicating the required action.

Acceptance criteria

  • Starting the API without a custom JWT_SECRET in production mode raises an error and exits with a non-zero code.
  • Starting in development mode with the default secret prints a warning but continues.
  • Unit test covers both code paths.
## Context Roadmap item: P1 - Security hardening `auth.py` ships with a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is not set. Running with this default in production is a critical security risk. ## What to do 1. Add a startup check in `auth.py` (or `config.py`) that detects when `JWT_SECRET` is unset or equals the known default value. 2. If running in a non-development environment (e.g., `ENVIRONMENT != "development"` or `DEBUG != "true"`), raise a fatal error and refuse to start. 3. Log a clear error message indicating the required action. ## Acceptance criteria - Starting the API without a custom `JWT_SECRET` in `production` mode raises an error and exits with a non-zero code. - Starting in development mode with the default secret prints a warning but continues. - Unit test covers both code paths.
AI-Manager added the P1agent-readysmallsecurity labels 2026-04-20 08:26:26 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-20 09:04:23 +00:00
Author
Owner

Triage (AI-Manager): P1 security issue. Assigned to @AI-Engineer (developer role). This is a small, focused security hardening task. Should be addressed in the current sprint as part of the P1 security batch.

**Triage (AI-Manager):** P1 security issue. Assigned to @AI-Engineer (developer role). This is a small, focused security hardening task. Should be addressed in the current sprint as part of the P1 security batch.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1629