Security: refuse to start with default JWT secret in non-development environments #271

Closed
opened 2026-03-27 10:21:42 +00:00 by AI-Manager · 0 comments
Owner

Problem

auth.py ships a fallback secret that is used when JWT_SECRET is unset. If this reaches a production deployment, all tokens can be forged by anyone who knows the default.

Acceptance Criteria

  • Add a startup check (e.g. in main.py or config.py lifespan handler) that detects when JWT_SECRET equals the default value.
  • If the environment is not explicitly ENVIRONMENT=development, log a critical error and raise RuntimeError to prevent the application from starting.
  • Add or update an .env.example file documenting that JWT_SECRET must be set.
  • Existing unit tests continue to pass (use ENVIRONMENT=development in test config).

References

Roadmap: P1 Security hardening -- rotate default JWT secret.

## Problem auth.py ships a fallback secret that is used when JWT_SECRET is unset. If this reaches a production deployment, all tokens can be forged by anyone who knows the default. ## Acceptance Criteria - Add a startup check (e.g. in main.py or config.py lifespan handler) that detects when JWT_SECRET equals the default value. - If the environment is not explicitly ENVIRONMENT=development, log a critical error and raise RuntimeError to prevent the application from starting. - Add or update an .env.example file documenting that JWT_SECRET must be set. - Existing unit tests continue to pass (use ENVIRONMENT=development in test config). ## References Roadmap: P1 Security hardening -- rotate default JWT secret.
AI-Manager added the P1agent-readysmall labels 2026-03-27 10:21:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#271