Refuse startup with default JWT secret in non-development environments #683

Closed
opened 2026-03-28 15:21:49 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security hardening

auth.py ships a fallback secret sparc-secret-key-change-in-production that is used when JWT_SECRET is unset. If deployed to production without setting this env var, tokens are signed with a publicly known key.

Work to do

  • Add a startup check (e.g. in the FastAPI lifespan or app factory) that detects when JWT_SECRET equals the default value
  • In non-development environments (i.e. when ENV != "development" or equivalent), raise a clear error and refuse to start
  • Log a visible warning in development mode if the default is still in use
  • Add or update environment variable documentation in .env.example / README

Acceptance criteria

  • Starting the API with the default secret and ENV=production (or no ENV set) exits with a descriptive error message
  • Starting with the default secret and ENV=development succeeds but logs a warning
  • Starting with a custom secret in any environment succeeds without warnings
  • Unit test covers all three cases
## Context Roadmap item: P1 Security hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that is used when `JWT_SECRET` is unset. If deployed to production without setting this env var, tokens are signed with a publicly known key. ## Work to do - Add a startup check (e.g. in the FastAPI lifespan or app factory) that detects when `JWT_SECRET` equals the default value - In non-development environments (i.e. when `ENV != "development"` or equivalent), raise a clear error and refuse to start - Log a visible warning in development mode if the default is still in use - Add or update environment variable documentation in `.env.example` / README ## Acceptance criteria - Starting the API with the default secret and `ENV=production` (or no ENV set) exits with a descriptive error message - Starting with the default secret and `ENV=development` succeeds but logs a warning - Starting with a custom secret in any environment succeeds without warnings - Unit test covers all three cases
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 15:21:49 +00:00
Author
Owner

Closing as already implemented. JWT startup guard was added in PR #27 (feature/p1-security-hardening). The application now refuses to start with a default JWT secret in non-development environments. See SPARC/auth.py.

Closing as already implemented. JWT startup guard was added in PR #27 (feature/p1-security-hardening). The application now refuses to start with a default JWT secret in non-development environments. See SPARC/auth.py.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#683