Fix hardcoded JWT secrets in .env.example and config/jwt.php (CWE-798) - #91
Open
saaa99999999 wants to merge 1 commit into
Open
Fix hardcoded JWT secrets in .env.example and config/jwt.php (CWE-798)#91saaa99999999 wants to merge 1 commit into
saaa99999999 wants to merge 1 commit into
Conversation
Removed the default hardcoded JWT secret fallbacks from .env.example and config/jwt.php. Added startup validation in AppServiceProvider that rejects empty, known-default, and short JWT secrets.
Author
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removed hardcoded JWT signing secret defaults from
.env.exampleandconfig/jwt.php. Added startup validation inAppServiceProviderthat rejects empty, known-default, and short JWT secrets.Details
.env.example:48:JWT_SECRET=my-dummy-token??empty withphp artisan jwt:secretgeneration instructions.config/jwt.php:28:env('JWT_SECRET', 'my-dummy-jwt-token')??env('JWT_SECRET')(no hardcoded code-level fallback).app/Providers/AppServiceProvider.php: Addedboot()validation that rejects:nullJWT_SECRETmy-dummy-token,my-dummy-jwt-token,secret,changeme,jwt_secret,your-secret-key)Security Impact
This project uses
tymon/jwt-authwith symmetric HMAC signing. The hardcoded secretmy-dummy-jwt-tokenwas present in two places:.env.example(template developers copy)env()inconfig/jwt.php(code-level fallback if the env var is missing)The code-level fallback is especially dangerous: even if no
.envfile exists, the application would silently start and usemy-dummy-jwt-tokento sign and verify all JWT tokens. Anyone who knows this key ??which is visible in the public GitHub repository ??can forge valid authentication tokens for any user.Before/After
config/jwt.php
.env.example
app/Providers/AppServiceProvider.php