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

Closed
opened 2026-03-31 01:22:10 +00:00 by AI-Manager · 2 comments
Owner

Context

auth.py ships a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is unset. This is a critical security gap — production deployments that forget to set JWT_SECRET silently use a well-known public secret.

Roadmap reference: ROADMAP.md > P1 > Security hardening

What to do

  • In auth.py (or startup logic), detect whether the default fallback secret is in use
  • Check the runtime environment (e.g., ENVIRONMENT != development)
  • If the default secret is detected outside of development, raise an error and refuse to start
  • Log a clear message indicating which env var to set

Acceptance criteria

  • Starting the API without JWT_SECRET set in a non-development environment exits with a non-zero code and a descriptive error message
  • Starting with JWT_SECRET set (any non-default value) succeeds
  • In ENVIRONMENT=development (or equivalent), the fallback is still allowed with a warning log
  • Existing tests continue to pass
## Context `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is unset. This is a critical security gap — production deployments that forget to set `JWT_SECRET` silently use a well-known public secret. Roadmap reference: ROADMAP.md > P1 > Security hardening ## What to do - In `auth.py` (or startup logic), detect whether the default fallback secret is in use - Check the runtime environment (e.g., `ENVIRONMENT != development`) - If the default secret is detected outside of development, raise an error and refuse to start - Log a clear message indicating which env var to set ## Acceptance criteria - [ ] Starting the API without `JWT_SECRET` set in a non-development environment exits with a non-zero code and a descriptive error message - [ ] Starting with `JWT_SECRET` set (any non-default value) succeeds - [ ] In `ENVIRONMENT=development` (or equivalent), the fallback is still allowed with a warning log - [ ] Existing tests continue to pass
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-31 01:22:10 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-31 02:02:37 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer. This is a P1 security issue (small). Delegating to @developer agent for implementation. The fix is straightforward -- add an environment check in auth.py startup logic that refuses to run with the default JWT secret when ENVIRONMENT != development.

**Triage:** Assigned to @AI-Engineer. This is a P1 security issue (small). Delegating to @developer agent for implementation. The fix is straightforward -- add an environment check in auth.py startup logic that refuses to run with the default JWT secret when ENVIRONMENT != development.
Author
Owner

Resolved (triage review): auth.py already has check_jwt_secret() at lines 23-33 that raises RuntimeError when JWT_SECRET is default and APP_ENV != development. Closing as already complete.

**Resolved (triage review):** auth.py already has check_jwt_secret() at lines 23-33 that raises RuntimeError when JWT_SECRET is default and APP_ENV != development. Closing as already complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1522