forked from 0xWheatyz/SPARC
Refuse startup with default JWT secret in non-development environments #335
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?
Problem
auth.pyships a fallbacksparc-secret-key-change-in-productionvalue that is used whenJWT_SECRETis unset. If this secret leaks or is left as default in production, all tokens can be forged.Work
lifespanormain.py) that readsJWT_SECRETfrom the environment.ENVIRONMENTis notdevelopmentordev, raise an error and refuse to start.os.environ.getpresence: ifJWT_SECRETis not set at all, also refuse in non-dev mode.Acceptance Criteria
JWT_SECRETandENVIRONMENT=productionexits with a non-zero code and a descriptive message.ENVIRONMENT=developmentand the default secret succeeds (dev convenience).JWT_SECRETin any environment succeeds.Reference
Roadmap item: Security hardening — Rotate default JWT secret.
[Repo Manager] This issue is resolved. auth.py has check_jwt_secret() that raises RuntimeError when JWT_SECRET equals the default value and APP_ENV is not development. It is called during app lifespan startup.