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

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

Summary

auth.py ships a fallback sparc-secret-key-change-in-production value that is used if the JWT_SECRET environment variable is unset. This means a misconfigured production deployment silently uses a known, public secret.

What to do

  • Add a startup check in auth.py (or app startup hook) that reads the configured JWT secret.
  • If the secret equals the default value AND the environment is not development (e.g. check APP_ENV env var), raise an error and refuse to start.
  • Log a clear error message indicating which env var needs to be set.

Acceptance Criteria

  • Application fails to start when JWT_SECRET is unset (or equals the default) and APP_ENV != development.
  • A descriptive error message is printed to stderr.
  • Unit test verifies the startup check raises an exception with the default secret in non-dev mode.
  • README or .env.example documents the required JWT_SECRET variable.

Reference

Roadmap: P1 Security hardening — Rotate default JWT secret.

## Summary `auth.py` ships a fallback `sparc-secret-key-change-in-production` value that is used if the `JWT_SECRET` environment variable is unset. This means a misconfigured production deployment silently uses a known, public secret. ## What to do - Add a startup check in `auth.py` (or app startup hook) that reads the configured JWT secret. - If the secret equals the default value AND the environment is not `development` (e.g. check `APP_ENV` env var), raise an error and refuse to start. - Log a clear error message indicating which env var needs to be set. ## Acceptance Criteria - [ ] Application fails to start when `JWT_SECRET` is unset (or equals the default) and `APP_ENV != development`. - [ ] A descriptive error message is printed to stderr. - [ ] Unit test verifies the startup check raises an exception with the default secret in non-dev mode. - [ ] README or `.env.example` documents the required `JWT_SECRET` variable. ## Reference Roadmap: P1 Security hardening — Rotate default JWT secret.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 16:21:37 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 17:02:59 +00:00
Author
Owner

[Repo Manager] Already resolved. check_jwt_secret() in auth.py (lines 23-33) is called at startup. Refuses to start with default secret when APP_ENV != development.

Closing as already implemented in the codebase.

[Repo Manager] Already resolved. check_jwt_secret() in auth.py (lines 23-33) is called at startup. Refuses to start with default secret when APP_ENV != development. Closing as already implemented in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#709