Skip to content

[BE-111] Hardcoded fallback JWT secrets in AuthService and JwtStrategy #1253

Description

@yusuftomilola

Overview

AuthService.generateAccessToken()/generateRefreshToken() and JwtStrategy's constructor all read the signing secret via configService.get<string>('JWT_SECRET', 'secretKey') / 'refreshSecretKey' (backend/src/auth/auth.service.ts, backend/src/auth/strategies/jwt.strategy.ts). If JWT_SECRET/JWT_REFRESH_SECRET is ever unset — a misconfigured environment, not just local dev — the app silently signs and verifies tokens with these literal strings from the source code, which anyone who has read the repo can forge.

Tasks

  • Fail fast at startup (in main.ts or a ConfigModule validation schema) if JWT_SECRET or JWT_REFRESH_SECRET is unset or shorter than a safe minimum length.
  • Remove the 'secretKey'/'refreshSecretKey' literal fallbacks from auth.service.ts and jwt.strategy.ts.
  • Document the required env vars in backend/.env.example with a comment that there is no default.
  • Add a unit test asserting the app fails to boot when the secret is missing.

Acceptance Criteria

  • Booting the app with JWT_SECRET unset throws instead of falling back to a guessable string.
  • No source file contains a literal fallback secret.

Notes for Contributors

Comment below to be assigned.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions