forked from 0xWheatyz/SPARC
Refuse startup with default JWT secret in non-development environments #1420
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?
Summary
auth.pyships a fallbacksparc-secret-key-change-in-productionsecret used whenJWT_SECRETis unset. Running with this default in production is a critical security risk.What to do
JWT_SECRETandAPP_ENV.APP_ENV != developmentandJWT_SECRETequals the default string, raiseRuntimeErrorand abort startup.Acceptance criteria
JWT_SECRETis the default andAPP_ENV != development.References
Roadmap: P1 Security hardening -- rotate default JWT secret.
This is already implemented in the current codebase.
SPARC/auth.pycontainscheck_jwt_secret()which raisesRuntimeErrorwhenJWT_SECRETequals the default value andAPP_ENV != "development". The function is called during the FastAPI lifespan startup hook inSPARC/api.py.SPARC/config.pydefinesapp_envfrom theAPP_ENVenvironment variable.Closing as completed.