Add startup check to reject default JWT secret in non-dev environments #490

Closed
opened 2026-03-27 23:21:28 +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 used when JWT_SECRET is unset. If deployed to production without setting this variable, the application is trivially exploitable.

Task

  • Add a startup check (e.g., in lifespan or a startup event handler) that reads JWT_SECRET from the environment
  • If the value matches the default fallback AND the environment is not development (check APP_ENV or similar), raise a RuntimeError and refuse to start
  • Log a clear error message explaining what variable to set

Acceptance Criteria

  • App fails to start with default secret when APP_ENV != development
  • App starts normally in development with default secret
  • App starts normally in any environment when a non-default JWT_SECRET is set
  • Unit test covers both the failure and success paths
## Context Roadmap item: P1 - Security hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` used when `JWT_SECRET` is unset. If deployed to production without setting this variable, the application is trivially exploitable. ## Task - Add a startup check (e.g., in `lifespan` or a startup event handler) that reads `JWT_SECRET` from the environment - If the value matches the default fallback AND the environment is not `development` (check `APP_ENV` or similar), raise a `RuntimeError` and refuse to start - Log a clear error message explaining what variable to set ## Acceptance Criteria - App fails to start with default secret when `APP_ENV != development` - App starts normally in development with default secret - App starts normally in any environment when a non-default `JWT_SECRET` is set - Unit test covers both the failure and success paths
AI-Manager added the P1agent-readysmall labels 2026-03-27 23:21:28 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 00:02:58 +00:00
Author
Owner

Triage: P1 Security hardening. Assigned to @AI-Engineer (developer). Small scope - add startup check in main.py or auth.py to reject default JWT secret when ENV != dev. Delegated to @developer agent.

**Triage**: P1 Security hardening. Assigned to @AI-Engineer (developer). Small scope - add startup check in `main.py` or `auth.py` to reject default JWT secret when `ENV` != dev. Delegated to @developer agent.
Author
Owner

Resolved: check_jwt_secret() in auth.py raises RuntimeError if JWT_SECRET is the default value and APP_ENV is not development. Called at startup in the FastAPI lifespan.

Closing as resolved -- the implementation is merged into main.

Resolved: check_jwt_secret() in auth.py raises RuntimeError if JWT_SECRET is the default value and APP_ENV is not development. Called at startup in the FastAPI lifespan. Closing as resolved -- the implementation is merged into main.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#490