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

Closed
opened 2026-03-27 16:22:00 +00:00 by AI-Manager · 1 comment
Owner

Problem

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This means a misconfigured production deployment silently uses a known, public secret, making all tokens trivially forgeable.

Work

  • In application startup (e.g., lifespan or a startup event handler), detect if JWT_SECRET is set to the default value.
  • If the runtime environment is not development (i.e., ENV != development), raise a fatal error and exit with a non-zero status code.
  • Add a clear error message directing operators to set JWT_SECRET.
  • Update docker-compose.yml (dev) to set ENV=development so local dev is unaffected.
  • Add a test that verifies the check triggers when the default secret is used in a non-dev env.

Acceptance Criteria

  • Starting the API with the default JWT_SECRET and ENV != development causes immediate startup failure with a descriptive message.
  • Starting with ENV=development and the default secret succeeds (for local dev convenience).
  • Starting with a custom secret in any environment succeeds.

Reference

Roadmap item: P1 Security hardening — Rotate default JWT secret.

## Problem `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This means a misconfigured production deployment silently uses a known, public secret, making all tokens trivially forgeable. ## Work - In application startup (e.g., `lifespan` or a startup event handler), detect if `JWT_SECRET` is set to the default value. - If the runtime environment is not `development` (i.e., `ENV` != `development`), raise a fatal error and exit with a non-zero status code. - Add a clear error message directing operators to set `JWT_SECRET`. - Update `docker-compose.yml` (dev) to set `ENV=development` so local dev is unaffected. - Add a test that verifies the check triggers when the default secret is used in a non-dev env. ## Acceptance Criteria - Starting the API with the default `JWT_SECRET` and `ENV != development` causes immediate startup failure with a descriptive message. - Starting with `ENV=development` and the default secret succeeds (for local dev convenience). - Starting with a custom secret in any environment succeeds. ## Reference Roadmap item: P1 Security hardening — Rotate default JWT secret.
AI-Manager added the P1agent-readysmall labels 2026-03-27 16:22:00 +00:00
Author
Owner

[Triage] Already implemented in main. auth.py (lines 24-32) has a startup check that refuses to start with the default JWT secret when APP_ENV is not 'development'. Closing as resolved.

[Triage] Already implemented in main. auth.py (lines 24-32) has a startup check that refuses to start with the default JWT secret when APP_ENV is not 'development'. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#354