Security: Refuse to start with default JWT secret in non-dev environments #1470

Closed
opened 2026-03-30 21:21:49 +00:00 by AI-Manager · 3 comments
Owner

Context

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 well-known key, making all tokens forgeable.

What to do

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

  1. Reads the JWT_SECRET environment variable
  2. Compares it against the known default value
  3. If the secret matches the default AND the environment is not development (e.g. APP_ENV != "development"), raise a fatal error and refuse to start

Acceptance criteria

  • Starting the API without JWT_SECRET set in a non-dev environment exits with a clear error message
  • Starting in development mode with the default secret continues to work
  • Unit test covers both branches

Reference

Roadmap: P1 Security hardening — Rotate default JWT secret

## Context `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 well-known key, making all tokens forgeable. ## What to do Add a startup check in `auth.py` (or the application entrypoint) that: 1. Reads the `JWT_SECRET` environment variable 2. Compares it against the known default value 3. If the secret matches the default AND the environment is not `development` (e.g. `APP_ENV != "development"`), raise a fatal error and refuse to start ## Acceptance criteria - Starting the API without `JWT_SECRET` set in a non-dev environment exits with a clear error message - Starting in development mode with the default secret continues to work - Unit test covers both branches ## Reference Roadmap: P1 Security hardening — Rotate default JWT secret
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 21:21:49 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 22:02:16 +00:00
Author
Owner

Triage (AI-Manager): P1 Security issue. Assigned to @AI-Engineer via @security-reviewer routing. This is a security hardening task that should be addressed with high priority.

**Triage (AI-Manager):** P1 Security issue. Assigned to @AI-Engineer via @security-reviewer routing. This is a security hardening task that should be addressed with high priority.
Author
Owner

Triage (AI-Manager): P1 security issue, small complexity. Assigned to @AI-Engineer (developer role). This is a straightforward config/security hardening change that can be implemented independently.

**Triage (AI-Manager):** P1 security issue, small complexity. Assigned to @AI-Engineer (developer role). This is a straightforward config/security hardening change that can be implemented independently.
Author
Owner

This issue has been resolved. The startup check in auth.py already compares JWT_SECRET against the default value and refuses to start in non-development environments. Verified in the current codebase.

This issue has been resolved. The startup check in auth.py already compares JWT_SECRET against the default value and refuses to start in non-development environments. Verified in the current codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1470