Security: Add startup check to reject default JWT secret in non-dev environments #467

Closed
opened 2026-03-27 22:21:24 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 - Security hardening

Problem

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if the JWT_SECRET environment variable is unset. This means a deployed instance can silently use a well-known, insecure secret.

Task

  • In auth.py (or application startup), detect when the current JWT_SECRET value matches the default string.
  • If running in a non-development environment (e.g., APP_ENV != development), raise a fatal error / refuse to start.
  • Log a clear error message explaining what the operator must do.
  • Update .env.example and any deployment docs to document the requirement.

Acceptance Criteria

  • Application refuses to start in production when JWT_SECRET is the default value.
  • A clear log/error message is emitted indicating the misconfiguration.
  • Development mode (APP_ENV=development) still starts fine with the default secret (with a warning).
  • Unit test covers both the pass and fail paths.
## Context Roadmap item: P1 - Security hardening ## Problem `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if the `JWT_SECRET` environment variable is unset. This means a deployed instance can silently use a well-known, insecure secret. ## Task - In `auth.py` (or application startup), detect when the current `JWT_SECRET` value matches the default string. - If running in a non-development environment (e.g., `APP_ENV != development`), raise a fatal error / refuse to start. - Log a clear error message explaining what the operator must do. - Update `.env.example` and any deployment docs to document the requirement. ## Acceptance Criteria - [ ] Application refuses to start in production when `JWT_SECRET` is the default value. - [ ] A clear log/error message is emitted indicating the misconfiguration. - [ ] Development mode (`APP_ENV=development`) still starts fine with the default secret (with a warning). - [ ] Unit test covers both the pass and fail paths.
AI-Manager added the P1agent-readysmall labels 2026-03-27 22:21:24 +00:00
Author
Owner

This has already been implemented. check_jwt_secret() exists in SPARC/auth.py (lines 23-33) and is called during app startup in SPARC/api.py. It raises RuntimeError if JWT_SECRET equals the default value and APP_ENV is not development. Closing as completed.

This has already been implemented. `check_jwt_secret()` exists in `SPARC/auth.py` (lines 23-33) and is called during app startup in `SPARC/api.py`. It raises `RuntimeError` if `JWT_SECRET` equals the default value and `APP_ENV` is not `development`. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#467