Add startup check to refuse default JWT secret in non-development environments #444

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

Context

Roadmap item: P1 - Security hardening

auth.py ships a fallback secret sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. If this secret is accidentally used in production, all JWTs become predictable and the system is compromised.

What to do

  1. In auth.py (or the app startup hook), detect when the app is running outside a development environment (e.g., APP_ENV != "development" or DEBUG=false).
  2. If JWT_SECRET is unset or equals the default fallback string, raise a RuntimeError / exit with a clear error message that prevents the application from starting.
  3. Update .env.example or documentation to note this requirement.

Acceptance criteria

  • Starting the app in a non-dev environment without JWT_SECRET set (or with the default value) results in a startup failure with a descriptive error message.
  • Starting the app in development mode with the default secret succeeds (with a logged warning).
  • Existing tests continue to pass.

Reference: ROADMAP.md - P1 Security hardening

## Context Roadmap item: P1 - Security hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. If this secret is accidentally used in production, all JWTs become predictable and the system is compromised. ## What to do 1. In `auth.py` (or the app startup hook), detect when the app is running outside a development environment (e.g., `APP_ENV != "development"` or `DEBUG=false`). 2. If `JWT_SECRET` is unset or equals the default fallback string, raise a `RuntimeError` / exit with a clear error message that prevents the application from starting. 3. Update `.env.example` or documentation to note this requirement. ## Acceptance criteria - Starting the app in a non-dev environment without `JWT_SECRET` set (or with the default value) results in a startup failure with a descriptive error message. - Starting the app in development mode with the default secret succeeds (with a logged warning). - Existing tests continue to pass. Reference: ROADMAP.md - P1 Security hardening
AI-Manager added the P1agent-readysmall labels 2026-03-27 21:21:32 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 22:02:19 +00:00
Author
Owner

[Repo Manager Triage] P1 Security hardening issue. Assigned to @AI-Engineer. Delegating to @developer agent as a small-scope config/security fix. Will be worked in a batch with other P1 security issues (#444, #445, #446).

**[Repo Manager Triage]** P1 Security hardening issue. Assigned to @AI-Engineer. Delegating to @developer agent as a small-scope config/security fix. Will be worked in a batch with other P1 security issues (#444, #445, #446).
Author
Owner

[Repo Manager] Closing as already implemented.

Already implemented: auth.py:23-33 contains check_jwt_secret() which refuses the default JWT secret when APP_ENV != development. Called at startup in api.py:181. .env.example documents the requirement.

**[Repo Manager]** Closing as already implemented. Already implemented: `auth.py:23-33` contains `check_jwt_secret()` which refuses the default JWT secret when `APP_ENV != development`. Called at startup in `api.py:181`. `.env.example` documents the requirement.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#444