forked from 0xWheatyz/SPARC
Refuse to start with default JWT secret in non-development environments #780
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
auth.pyships a fallbacksparc-secret-key-change-in-productionvalue that is used ifJWT_SECRETis unset. If the application is deployed without setting this env var, all JWT tokens share the same well-known secret, which is a critical security hole.Roadmap reference: ROADMAP.md -- P1 Security hardening -- "Rotate default JWT secret"
What to do
auth.py(or startup code), detect whenJWT_SECRETequals the default fallback string.APP_ENV(defaulting toproduction).APP_ENV != development, raise aRuntimeErroror callsys.exit(1)with a clear error message instructing the operator to setJWT_SECRET.Acceptance criteria
JWT_SECRETset andAPP_ENV=productioncauses an immediate startup failure with a descriptive error message.APP_ENV=developmentand the default secret logs a warning but does not exit.Triage: Assigned to @developer. Reason: P1 security, small - straightforward startup check. Dispatching agent now.
Already implemented -- closing.
check_jwt_secret()exists inSPARC/auth.py(lines 23-33). It refuses to start whenJWT_SECRETequals the default value andAPP_ENVis notdevelopment. It is called at app startup inSPARC/api.pyline 181 via thelifespancontext manager. The.env.examplefile documents theAPP_ENVandJWT_SECRETvariables.No further work needed.