Skip to content

[HIGH] — JWT strategy and WebSocket gateway fall back to insecure hardcoded strings when JWT_SECRET is unset, allowing weak-secret boots in any environment #3

Description

@Alqku

Severity: High
Type: Security hardening
Scope: Auth, Notifications
Labels: security, refactoring, Official Campaign

Description

Two separate code paths accept a default secret when JWT_SECRET is not present in the environment, instead of failing fast:

  • JwtStrategy (src/auth/jwt.strategy.ts, line ~12): secretOrKey: configService.get<string>('JWT_SECRET', 'default-secret').
  • NotificationsGateway.handleConnection (src/notifications/notifications.gateway.ts, line ~65): this.configService.get<string>('JWT_SECRET', 'orbitchain-default-secret').

Neither module logs a warning at boot when the fallback is used, and the ConfigModule is not validated at application startup (src/main.ts does not call validate on ConfigService). A misconfigured production deployment can therefore boot against a known constant string that an attacker can forge a token for.

Recommendation

  • Remove both default-value fallbacks and throw an Error at module construction if JWT_SECRET is missing or shorter than, e.g., 32 bytes.
  • Add a ConfigValidationSchema (e.g., class-validator) on ConfigModule.forRoot({ validate }) that requires JWT_SECRET, STELLAR_RPC_URL, STELLAR_NETWORK_PASSPHRASE, REDIS_URL, DATABASE_URL.
  • Centralise JWT verification options in a single @Injectable() provider so the gateway and the HTTP strategy cannot drift apart.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignAudit finding under the Official CampaignrefactoringCode restructuring without behavioural changesecuritySecurity vulnerability or hardening

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions