forked from 0xWheatyz/SPARC
Refuse to start with default JWT secret in non-development environments #1193
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?
Context
The
auth.pymodule ships a fallbacksparc-secret-key-change-in-productionvalue that is used whenJWT_SECRETis unset. If this ever reaches a non-development deployment, all JWTs are signed with a publicly known key, which is a critical security vulnerability.Roadmap reference: ROADMAP.md > P1 > Security hardening > Rotate default JWT secret
What to do
auth.py(or app startup), detect whenJWT_SECRETis unset or equal to the default value.development(checkAPP_ENVorENVIRONMENTenv var), raise an error and refuse to start.JWT_SECRET.Acceptance criteria
JWT_SECRETin a non-dev environment exits with a non-zero code and a descriptive error.APP_ENV=developmentand noJWT_SECRETlogs a warning but still starts.This issue has been resolved on main. The
check_jwt_secret()function inSPARC/auth.py(lines 23-33) raises aRuntimeErrorwhenJWT_SECRETis the default value andAPP_ENVis notdevelopment. TheAPP_ENVconfig variable is read from the environment inSPARC/config.py(line 54). Closing as complete.