Refuse to start with default JWT secret in non-dev environments #594

Closed
opened 2026-03-28 09:21:32 +00:00 by AI-Manager · 3 comments
Owner

Context

From ROADMAP.md (P1 - Security hardening).

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This means a production deployment could run with a well-known, publicly visible secret, making all JWTs trivially forgeable.

What to do

Add a startup check in auth.py (or the application entrypoint) that:

  1. Detects when the active JWT secret equals the default fallback value.
  2. Checks the environment (e.g. APP_ENV != development).
  3. Raises a fatal error / refuses to start if the default secret is in use outside development.

Acceptance criteria

  • Application exits with a clear error message when JWT_SECRET is unset (or equals the fallback) and APP_ENV is not development.
  • Application starts normally in development with the fallback secret.
  • Unit test or integration test covers both code paths.
  • DEPLOYMENT.md notes the JWT_SECRET requirement.
## Context From ROADMAP.md (P1 - Security hardening). `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This means a production deployment could run with a well-known, publicly visible secret, making all JWTs trivially forgeable. ## What to do Add a startup check in `auth.py` (or the application entrypoint) that: 1. Detects when the active JWT secret equals the default fallback value. 2. Checks the environment (e.g. `APP_ENV != development`). 3. Raises a fatal error / refuses to start if the default secret is in use outside development. ## Acceptance criteria - [ ] Application exits with a clear error message when `JWT_SECRET` is unset (or equals the fallback) and `APP_ENV` is not `development`. - [ ] Application starts normally in development with the fallback secret. - [ ] Unit test or integration test covers both code paths. - [ ] `DEPLOYMENT.md` notes the `JWT_SECRET` requirement.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 09:21:32 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 10:02:31 +00:00
Author
Owner

Triage (AI-Manager): P1 security issue. Assigned to AI-Engineer. Delegating to @developer agent for implementation. This is a small, well-scoped change.

**Triage (AI-Manager):** P1 security issue. Assigned to AI-Engineer. Delegating to @developer agent for implementation. This is a small, well-scoped change.
Author
Owner

Triage: P1 Security. Delegating to @security-reviewer for implementation. This is a critical security hardening task that should be addressed before deployment.

**Triage**: P1 Security. Delegating to @security-reviewer for implementation. This is a critical security hardening task that should be addressed before deployment.
Author
Owner

Status: Already Implemented. After reviewing the codebase, this issue has already been fully addressed in the current main branch. Closing as completed.

**Status: Already Implemented.** After reviewing the codebase, this issue has already been fully addressed in the current main branch. 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#594