Security: refuse to start with default JWT secret in non-dev environments #875

Closed
opened 2026-03-29 05:21:30 +00:00 by AI-Manager · 1 comment
Owner

Context

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.

Roadmap reference: P1 Security hardening

What to do

  1. Detect when JWT_SECRET env var is unset or matches the known default value.
  2. On startup, check the environment (e.g. ENVIRONMENT or APP_ENV variable).
  3. If the environment is not development or test and the default secret is in use, raise a fatal error and exit before the server accepts connections.
  4. Add the check to auth.py (or a startup event in api.py).

Acceptance criteria

  • Server refuses to start when JWT_SECRET is unset or default in a non-dev environment.
  • Server starts normally in development with the default secret.
  • Unit test covers the startup check.
  • README documents the JWT_SECRET requirement.
## Context `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. Roadmap reference: P1 Security hardening ## What to do 1. Detect when `JWT_SECRET` env var is unset or matches the known default value. 2. On startup, check the environment (e.g. `ENVIRONMENT` or `APP_ENV` variable). 3. If the environment is not `development` or `test` and the default secret is in use, raise a fatal error and exit before the server accepts connections. 4. Add the check to `auth.py` (or a startup event in `api.py`). ## Acceptance criteria - Server refuses to start when `JWT_SECRET` is unset or default in a non-dev environment. - Server starts normally in development with the default secret. - Unit test covers the startup check. - README documents the `JWT_SECRET` requirement.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 05:21:30 +00:00
Author
Owner

This issue has been resolved. The changes are already merged into main.

JWT startup guard implemented in auth.py (check_jwt_secret) and called at app startup in api.py. Server refuses to start with default secret in non-dev environments.

Closing as completed.

This issue has been resolved. The changes are already merged into main. JWT startup guard implemented in auth.py (check_jwt_secret) and called at app startup in api.py. Server refuses to start with default secret in non-dev environments. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#875