forked from 0xWheatyz/SPARC
Security: refuse to start with default JWT secret in non-development environments #1309
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
auth.pyships a fallbacksparc-secret-key-change-in-productionvalue that will be used ifJWT_SECRETis unset. This is a critical security risk if the application is accidentally deployed to production without setting the secret.What to do
auth.py(or startup/lifespan code), read theJWT_SECRETenvironment variable.sparc-secret-key-change-in-productionAND theENVIRONMENT(orAPP_ENV) variable is notdevelopment, raise a clearRuntimeErrorthat prevents the application from starting..env.example/ documentation explaining the requirement.Acceptance criteria
pytestpasses withAPP_ENV=developmentand the default secret.References
Roadmap: P1 Security hardening — Rotate default JWT secret.
Already resolved.
check_jwt_secret()inSPARC/auth.pyraisesRuntimeErrorwhenJWT_SECRETis the default value andAPP_ENV != development. Called at startup inapi.pylifespan. Tests intests/test_security.py.