forked from 0xWheatyz/SPARC
Add startup check to reject default JWT secret in non-dev environments #1375
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
Roadmap item: P1 Security hardening — Rotate default JWT secret
auth.pyships a hardcoded fallbacksparc-secret-key-change-in-productionthat is used whenJWT_SECRETis unset. This means a misconfigured production deployment silently uses a publicly known secret, allowing token forgery.Task
Add a startup guard in
auth.py(or the FastAPI app startup event) that:JWT_SECRETenvironment variable.sparc-secret-key-change-in-productionand theAPP_ENV(or equivalent) is notdevelopment, raises aRuntimeErrorand refuses to start.JWT_SECRETis unset entirely, raises aRuntimeErrorin all environments.Acceptance Criteria
JWT_SECRETis the default value outside ofdevelopmentmode.JWT_SECRETis provided.developmentenvironment bypasses the check (to keep local dev easy).docker-compose.ymldocumentsJWT_SECRETas a required variable with a comment.Reference
See ROADMAP.md § P1 Security hardening.
Resolved by PR #27 (merged). The
check_jwt_secret()function inauth.pyrejects the default JWT secret whenAPP_ENVis notdevelopment. Called during app lifespan startup.