forked from 0xWheatyz/SPARC
Refuse to start with default JWT secret in non-dev environments #1443
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
Problem
auth.pyships with a fallbacksparc-secret-key-change-in-productionsecret that is used whenJWT_SECRETis unset. If this secret leaks into a production deployment, all tokens are trivially forgeable.What to do
auth.py(or a startup hook inmain.py), check whetherJWT_SECRETequals the default value.ENV != "development"), raise aRuntimeErrorand exit with a non-zero code.JWT_SECRET.Acceptance criteria
ENV=productionexits immediately with a descriptive error.ENV=developmentlogs a warning but continues.JWT_SECRETworks regardless ofENV.[Triage] P1 security/config issue. Assigned to @AI-Engineer. Dispatching to @developer agent for implementation. This is a small, well-scoped change.
[Verification] All acceptance criteria met. Verified complete.
check_jwt_secret()inSPARC/auth.py(lines 23-33) raisesRuntimeErrorwhenJWT_SECRETequals the default andAPP_ENV != development. Called at startup via lifespan inapi.py. Tests intests/test_security.pycover all scenarios (production raises, development allows, custom secret works). Closing as implemented.