fix: remove hardcoded JWT secret defaults from config files (CWE-798) - #7
saaa99999999 wants to merge 1 commit into
Conversation
Replace hardcoded JWT secret key defaults in .env.example ("Change me!")
and docker-compose files with empty/required placeholders that force the
application to fail on startup if JWT_SECRET_KEY is not configured.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CVE Request — Action Needed from MaintainerThis PR fixes security vulnerabilities. To assign a CVE number: GitHub only issues CVEs from the official upstream repository, not from forks. Please:
If you prefer, I can submit the CVE via MITRE (cveform.mitre.org) instead — just let me know. Thank you for reviewing this PR! |
|
Hi there thank you for creating this pull request! Haven't been able to reply sooner. What do you recommend me to do, to at least handle this in a respectful way. |
|
Thanks for the kind reply, and no worries about the delay. Regarding the CVE question — honestly, for a 42-star repo, the fix itself matters more than the CVE. The PR removes the hardcoded JWT keys so anyone deploying this won't be vulnerable to token forgery. That's the important part. If you do want a CVE, the process is simple: merge the PR, then go to Security → Advisories → New draft, add @saaa99999999 as collaborator, and I fill in the rest. But there's no requirement to do this. The fix already protects users. A middle ground: merge the PR, and I can submit the CVE directly via MITRE on my end so you don't have to deal with the GitHub advisory process. Either way works. As for updating the dependencies — that's orthogonal to the security fix. The JWT key issue is independent of library versions. You can do that separately whenever it makes sense. |
Summary
Three config files contain hardcoded or weak JWT secret defaults that allow token forgery:
.env.example:67—JWT_SECRET_KEY="Change me!"— a weak placeholderdocker-compose.yml:51—JWT_SECRET_KEY=${JWT_SECRET_KEY:-fgr4fe34w2rfTwfe3444234edfewfw4e#f$#wferg23w2DFSdf}— hardcoded string visible in public repodocker-compose.loadbalanced.yml:98—JWT_SECRET_KEY=${JWT_SECRET_KEY:-Change me!}— same weak placeholderThe application uses
jsonwebtoken::encode()andjsonwebtoken::decode()withEncodingKey::from_secret()/DecodingKey::from_secret()via HS256 (symmetric). Anyone who reads the repo can forge valid JWT tokens and authenticate as any user.Data Flow
.env.example:67→docker-compose.yml:51— Secret flows from env file to containersrc/utils/auth.rs:26-27—SECRET_KEYloaded vialazy_static!fromget_env("JWT_SECRET_KEY")(panics if missing)src/utils/auth.rs:103-107— Token signing:src/utils/auth.rs:115-136— Token verification:The
get_env("JWT_SECRET_KEY")function already panics at startup if the env var is missing — this is good. But the docker-compose defaults silently supply a hardcoded key, preventing the panic from triggering.Fix
.env.example:66-69Before:
After:
docker-compose.yml:51Before:
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-fgr4fe34w2rfTwfe3444234edfewfw4e#f$#wferg23w2DFSdf}After:
docker-compose.loadbalanced.yml:98Same Docker Compose fix —
${JWT_SECRET_KEY:-Change me!}→${JWT_SECRET_KEY:?required ...}The
${VAR:?message}syntax causes Docker Compose to fail with a clear error message if the variable is not set, rather than silently falling back to a hardcoded value. Combined with the existingget_env()panic in the application code, this provides defense in depth: Docker Compose catches the missing variable before the container even starts.Impact
"Change me!"is a weak placeholder that a developer might not change.fgr4fe34w2rfTwfe...is a pseudo-random string but is compromised because it is public.