forked from 0xWheatyz/SPARC
Refuse to start when default JWT secret is used in non-dev environments #1400
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
Roadmap item: P1 -- Security hardening
auth.pyships a fallback secretsparc-secret-key-change-in-productionthat is used when theJWT_SECRETenvironment variable is unset. If this reaches a production deployment without being overridden, all tokens are trivially forgeable.What to do
lifespanor at module import time) that inspects the resolved JWT secret value.development(check aSPARC_ENVorAPP_ENVenv var), raise aRuntimeErroror callsys.exit(1)with a clear message.README.mdor a.env.examplefile.Acceptance criteria
APP_ENV=productioncauses an immediate, descriptive failure.APP_ENV=development(or unset) succeeds with a warning log.Triage: Already resolved in main.
check_jwt_secret()is implemented inSPARC/auth.py(lines 23-33) and called at startup inSPARC/api.py(line 181). Tests covering this behavior exist intests/test_security.py. Closing as complete.