forked from 0xWheatyz/SPARC
Add startup check to reject default JWT secret in non-development environments #1496
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 ifJWT_SECRETis unset. If this reaches a production environment the application will silently operate with a well-known secret, making all JWT tokens trivially forgeable.What to do
auth.py(or the startup lifecycle), read the currentJWT_SECRETvalue.sparc-secret-key-change-in-production.development(checkENVIRONMENTenv var), raise aRuntimeError/ callsys.exit(1)with a clear message before the app accepts any requests.JWT_SECRETis the default andENVIRONMENT=production.Acceptance criteria
JWT_SECRETequals the default value andENVIRONMENT != development[Repo Manager] This issue is already resolved in the current codebase. The
check_jwt_secret()function inSPARC/auth.pyrejects the default JWT secret whenAPP_ENVis notdevelopment. It is called during app startup inapi.py:lifespan(). Closing as complete.