Skip to content

fix: require explicit production jwt secrets#26

Merged
thunderavi merged 2 commits into
thunderavi:mainfrom
sahilsultane:fix/require-production-jwt-secrets
May 29, 2026
Merged

fix: require explicit production jwt secrets#26
thunderavi merged 2 commits into
thunderavi:mainfrom
sahilsultane:fix/require-production-jwt-secrets

Conversation

@sahilsultane
Copy link
Copy Markdown
Contributor

Summary

This PR fixes insecure JWT secret fallback behavior across authentication-related modules.

Closes #10

What Changed

  • Added centralized JWT secret validation helper

  • Removed unsafe default JWT secrets in production mode

  • Added validation for:

    • missing secrets
    • weak secrets
    • known default/dev secrets
  • Preserved development-mode compatibility with warnings/ephemeral secrets

  • Updated:

    • core/auth.js
    • core/realtime.js
    • core/enterpriseAuth.js
  • Added comprehensive test coverage for production and development scenarios

  • Updated .env.example with stronger secret guidance

Testing

Successfully passed:

  • npm test
  • npm run typecheck
  • npm run verify

Security Impact

Production deployments now fail fast when insecure JWT secrets are configured, preventing predictable-token vulnerabilities caused by framework default secrets.

GSSoC 2026

Please add:

*gssoc
*gssoc-approved
*quality clean
*security
*enhancement
*level: critical

@thunderavi thunderavi moved this from Backlog to In progress in @thunderavi's Easy.Js May 27, 2026
@thunderavi thunderavi self-requested a review May 27, 2026 18:31
Copy link
Copy Markdown
Owner

@thunderavi thunderavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sahilsultane, thanks for the PR. The overall approach is good and CI is passing, but I found one security blocker before merge.

In .env.example, these placeholder secrets are added:

REFRESH_TOKEN_SECRET=your-refresh-secret-here-change-in-production
JWT_REFRESH_SECRET=your-jwt-refresh-secret-here-change-in-production

Right now validateJwtSecret() accepts both in production because they are longer than 32 characters and are not included in KNOWN_DEFAULTS.

Please fix this by either:

  1. adding these exact placeholder values to KNOWN_DEFAULTS, or
  2. adding generic placeholder detection for values like your-*, *-change-in-production, replace-me, change-this, etc.

Also add/update tests to confirm these refresh-token placeholders are rejected in production.

After this fix and green CI, we can approve and merge.

@sahilsultane sahilsultane requested a review from thunderavi May 29, 2026 05:06
Copy link
Copy Markdown
Owner

@thunderavi thunderavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sahilsultane, thanks for updating the PR and addressing the security review feedback.

I reviewed the latest approach. The placeholder JWT secret detection is now added, the refresh-token placeholders are rejected in production, and the new tests cover the requested cases.

I also verified locally:

npm test -- tests/unit/jwtSecretValidator.test.js --runInBand
npm run verify
npm run typecheck
npm test -- --runInBand

All passed locally. Approving this PR now.

Please star the project. It is necessary for me because it helps the repository reach more contributors and supports the project visibility.

@thunderavi thunderavi moved this from In progress to Done in @thunderavi's Easy.Js May 29, 2026
@thunderavi thunderavi added gssoc:approved Approved for GSSoC scoring mentor:thunderavi Reviewed by thunderavi level:critical Critical-level contribution quality:clean Clean implementation quality type:security Security hardening or vulnerability fix labels May 29, 2026
@thunderavi thunderavi merged commit ebc9b21 into thunderavi:main May 29, 2026
@thunderavi
Copy link
Copy Markdown
Owner

Hi @sahilsultane, your PR has been reviewed and merged. Thank you for the clean security contribution.

Please star⭐ the repository as well. It is important for me because it helps the project reach more contributors and grow in the open-source community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC scoring level:critical Critical-level contribution mentor:thunderavi Reviewed by thunderavi quality:clean Clean implementation quality type:security Security hardening or vulnerability fix

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Require explicit production JWT secrets across auth and realtime modules

2 participants