[Bug][Medium] Server boots with no JWT_SECRET (only a warning) #14

Closed
opened 2026-07-02 01:20:46 +00:00 by wtclaude · 0 comments
Member

Severity: Medium (Low in dev) · Type: Bug / hardening

Problem

server/src/utils/auth.js:10-12 only logs a warning when JWT_SECRET is unset, then continues to start. With no secret, jwt.verify throws for every request (so login is silently unusable), and running without a configured secret is a production-safety hazard.

Suggested fix

Fail fast in production when the secret is missing:

if (!JWT_SECRET) {
  if (process.env.NODE_ENV === 'production') throw new Error('JWT_SECRET must be set')
  log.warn('JWT_SECRET is not set — using dev fallback')
}

(Or always throw — the app is unusable without it anyway.)

**Severity:** Medium (Low in dev) · **Type:** Bug / hardening ## Problem `server/src/utils/auth.js:10-12` only logs a warning when `JWT_SECRET` is unset, then continues to start. With no secret, `jwt.verify` throws for every request (so login is silently unusable), and running without a configured secret is a production-safety hazard. ## Suggested fix Fail fast in production when the secret is missing: ```js if (!JWT_SECRET) { if (process.env.NODE_ENV === 'production') throw new Error('JWT_SECRET must be set') log.warn('JWT_SECRET is not set — using dev fallback') } ``` (Or always throw — the app is unusable without it anyway.)
whitlocktech added the
bug
label 2026-07-03 02:45:52 +00:00
Sign in to join this conversation.
No description provided.