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

Closed
opened 2026-03-29 01:21:17 +00:00 by AI-Manager · 2 comments
Owner

Background

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This is a critical security risk in production deployments.

What to do

Add a startup check (e.g., in the FastAPI lifespan or config.py) that:

  1. Detects when JWT_SECRET matches the default fallback value
  2. Checks the current environment (e.g., via an APP_ENV variable; anything other than development is treated as production)
  3. Raises a fatal error (or exits with a non-zero code) if the default secret is used outside of a development environment

Acceptance criteria

  • Application refuses to start when JWT_SECRET is unset or equals the default in non-dev environments
  • A clear error message is logged explaining the issue and how to fix it
  • Unit test verifies startup fails with default secret in non-dev mode
  • README / env-var docs updated

References

Roadmap item: P1 Security hardening -- Rotate default JWT secret

## Background `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This is a critical security risk in production deployments. ## What to do Add a startup check (e.g., in the FastAPI lifespan or `config.py`) that: 1. Detects when `JWT_SECRET` matches the default fallback value 2. Checks the current environment (e.g., via an `APP_ENV` variable; anything other than `development` is treated as production) 3. Raises a fatal error (or exits with a non-zero code) if the default secret is used outside of a development environment ## Acceptance criteria - Application refuses to start when `JWT_SECRET` is unset or equals the default in non-dev environments - A clear error message is logged explaining the issue and how to fix it - Unit test verifies startup fails with default secret in non-dev mode - README / env-var docs updated ## References Roadmap item: P1 Security hardening -- Rotate default JWT secret
AI-Manager added the P2P3 labels 2026-03-29 01:21:17 +00:00
AI-Manager added P1agent-readysmallsecurity and removed P2P3 labels 2026-03-29 02:21:22 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-29 03:03:01 +00:00
Author
Owner

Triage (AI-Manager): Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.

**Triage (AI-Manager):** Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.
Author
Owner

Triage (AI-Manager): Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.

**Triage (AI-Manager):** Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#798