Refuse to start with default JWT secret in non-development environments #1193

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

Context

The auth.py module ships a fallback sparc-secret-key-change-in-production value that is used when JWT_SECRET is unset. If this ever reaches a non-development deployment, all JWTs are signed with a publicly known key, which is a critical security vulnerability.

Roadmap reference: ROADMAP.md > P1 > Security hardening > Rotate default JWT secret

What to do

  1. In auth.py (or app startup), detect when JWT_SECRET is unset or equal to the default value.
  2. If the environment is not development (check APP_ENV or ENVIRONMENT env var), raise an error and refuse to start.
  3. Log a clear error message explaining what is wrong and what the operator must do.
  4. Add a note to the README / docker-compose example about setting JWT_SECRET.

Acceptance criteria

  • Starting the API without setting JWT_SECRET in a non-dev environment exits with a non-zero code and a descriptive error.
  • Starting with APP_ENV=development and no JWT_SECRET logs a warning but still starts.
  • Existing tests continue to pass.
## Context The `auth.py` module ships a fallback `sparc-secret-key-change-in-production` value that is used when `JWT_SECRET` is unset. If this ever reaches a non-development deployment, all JWTs are signed with a publicly known key, which is a critical security vulnerability. Roadmap reference: ROADMAP.md > P1 > Security hardening > Rotate default JWT secret ## What to do 1. In `auth.py` (or app startup), detect when `JWT_SECRET` is unset or equal to the default value. 2. If the environment is not `development` (check `APP_ENV` or `ENVIRONMENT` env var), raise an error and refuse to start. 3. Log a clear error message explaining what is wrong and what the operator must do. 4. Add a note to the README / docker-compose example about setting `JWT_SECRET`. ## Acceptance criteria - [ ] Starting the API without setting `JWT_SECRET` in a non-dev environment exits with a non-zero code and a descriptive error. - [ ] Starting with `APP_ENV=development` and no `JWT_SECRET` logs a warning but still starts. - [ ] Existing tests continue to pass.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 04:21:48 +00:00
Author
Owner

This issue has been resolved on main. The check_jwt_secret() function in SPARC/auth.py (lines 23-33) raises a RuntimeError when JWT_SECRET is the default value and APP_ENV is not development. The APP_ENV config variable is read from the environment in SPARC/config.py (line 54). Closing as complete.

This issue has been resolved on main. The `check_jwt_secret()` function in `SPARC/auth.py` (lines 23-33) raises a `RuntimeError` when `JWT_SECRET` is the default value and `APP_ENV` is not `development`. The `APP_ENV` config variable is read from the environment in `SPARC/config.py` (line 54). Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1193