forked from 0xWheatyz/SPARC
Refuse startup with default JWT secret in non-development environments #1094
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 is used whenJWT_SECRETis unset. This means any deployed instance that forgets to set the environment variable uses a well-known public secret, making all JWTs trivially forgeable.What to do
Add a startup check (e.g., in a FastAPI
lifespanfunction or module-level guard) that:JWT_SECRETfrom the environment.developmentmode (check aSPARC_ENVorAPP_ENVvariable), raises aRuntimeErrorwith a clear message and refuses to start.Also update
docker-compose.ymland any.env.exampleto document thatJWT_SECRETmust be set.Acceptance criteria
pytesttest: starting withJWT_SECRET=sparc-secret-key-change-in-productionandAPP_ENV=productionraises an error.APP_ENV=developmentand the default secret logs a warning but does not raise..env.exampledocumentsJWT_SECRET.Roadmap reference: P1 - Security hardening
This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.