🛡️ Sentinel: Fix weak JWT_SECRET validation on L5 API#315
Conversation
…I L5 Co-authored-by: dcplatforms <10982057+dcplatforms@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 72e5f2d. Configure here.
| const isWeakSecret = (secret) => { | ||
| if (!secret) return true; | ||
| return WEAK_SECRETS.includes(secret.toLowerCase().trim()); | ||
| }; |
There was a problem hiding this comment.
Whitespace JWT secret bypasses gate
High Severity
The isWeakSecret check incorrectly treats whitespace-only JWT_SECRET values as strong in production. This bypasses the new security hardening for authentication and login, allowing an effectively empty and forgeable JWT secret to be used.
Reviewed by Cursor Bugbot for commit 72e5f2d. Configure here.
| if (process.env.NODE_ENV === 'production' && isWeakSecret(JWT_SECRET)) { | ||
| console.error('[Security] JWT_SECRET is weak, insecure, or default. Blocking login in production.'); | ||
| return res.status(500).json({ error: 'Internal server configuration error' }); | ||
| } |
There was a problem hiding this comment.
Login limiter before secret check
Medium Severity
The loginRateLimiter on POST /auth/login runs before the weak JWT_SECRET check. This means requests failing due to a weak secret configuration (returning a 500 error) still increment the rate limit, potentially leading to 429 errors that obscure the underlying configuration issue.
Reviewed by Cursor Bugbot for commit 72e5f2d. Configure here.


Sentinel Security Hardening: This change hardens the JWT authentication middleware and login handlers inside services/05-driver-experience-api/index.js. In production environments, any attempt to use weak, default, or insecure secrets (such as dev_secret_change_in_production, test_secret, dev_secret, default_secret, secret) is securely blocked and results in an internal server configuration error (500). Includes a comprehensive security unit test suite in security.test.js which validates these behaviors.
PR created automatically by Jules for task 18418571999193488544 started by @dcplatforms
Note
Medium Risk
Changes authentication behavior in production misconfigurations (intentional fail-closed) and could lock out the API if secrets are not set correctly; otherwise limited to config gating and test harness wiring.
Overview
Production JWT hardening on the L5 Driver Experience API: when
NODE_ENVisproduction, login and allauthenticateToken-protected routes now refuse to run ifJWT_SECRETis missing, default, or on a denylist of known weak values (dev_secret_change_in_production,secret, etc.), returning a generic 500 configuration error instead of issuing or accepting tokens.The service is refactored so
appis exported and the HTTP listener only starts underrequire.main === module, enabling supertest coverage without binding a port. A newsecurity.test.jsexercises health, blocked login/auth with default/weak secrets in production, and successful/auth/mewith a strong secret (realjwt.verify, not mocked middleware).Sentinel journal documents the weak-default JWT lesson and a minor title update.
Reviewed by Cursor Bugbot for commit 72e5f2d. Configure here.