Skip to content

fix: remove hardcoded JWT signing secrets from .env_rename_me - #84

Open
saaa99999999 wants to merge 1 commit into
Massad:masterfrom
saaa99999999:fix/hardcoded-secrets-env
Open

fix: remove hardcoded JWT signing secrets from .env_rename_me#84
saaa99999999 wants to merge 1 commit into
Massad:masterfrom
saaa99999999:fix/hardcoded-secrets-env

Conversation

@saaa99999999

Copy link
Copy Markdown

Summary

The file (intended to be copied to ) contains hardcoded JWT signing secrets. These are used directly as HMAC-SHA256 keys to sign and verify all access and refresh tokens. Anyone who reads the public repository knows the exact signing keys.

Vulnerable Code

Hardcoded Secrets

** (BEFORE):**

How Secrets Are Used

**** — Access tokens signed with :

**** — Refresh tokens signed with :

**** — Token verification uses :

**** — Refresh token verification uses :

Data Flow

Impact

  • CWE-798: Use of Hard-coded Credentials
  • An attacker who reads the public repository knows the exact signing keys
  • Can forge valid JWT access tokens for any
  • Can forge valid JWT refresh tokens and use the endpoint
  • The refresh endpoint performs token rotation (deletes old refresh UUID from Redis), so a forged refresh token can also invalidate a legitimate user session
  • All -protected endpoints are bypassed

Fix

1. Remove hardcoded values from

** (AFTER):**

2. Add startup validation in

** (ADDED):**

This ensures the application refuses to start if any of the three secrets are not set, forcing developers to generate cryptographically random keys before deploying.

Additional Note

uses (cost factor 10) for password hashing. Modern OWASP recommendations suggest cost 12+. Consider increasing this in a separate update.

The .env_rename_me file contained hardcoded JWT signing keys:
  ACCESS_SECRET="ashasdjhjhjadhasdaa123"
  REFRESH_SECRET="hjsajdhkjhf41jhagggdga"
  REDIS_SECRET="hjfhjhasdfkyuy2"

These are used directly to sign and verify all JWTs via HS256.
Anyone who reads the public repository knows the exact signing keys
and can forge valid access/refresh tokens for any user, bypassing
all authentication.

Added startup validation in main.go to reject empty secrets.
Now the application will refuse to start if ACCESS_SECRET,
REFRESH_SECRET, or REDIS_SECRET are not set, forcing developers
to generate cryptographically random keys.

Co-Authored-By: Security Researcher <security@example.com>
@saaa99999999

Copy link
Copy Markdown
Author

CVE Request — Action Needed from Maintainer

This PR fixes security vulnerabilities. To assign a CVE number:

GitHub only issues CVEs from the official upstream repository, not from forks.

Please:

  1. Go to this repo → SecurityAdvisoriesNew draft security advisory
  2. Add @saaa99999999 as a collaborator
  3. I will populate the full vulnerability details (CVSS, CWE, data flow, PoC) and submit the CVE request

If you prefer, I can submit the CVE via MITRE (cveform.mitre.org) instead — just let me know.

Thank you for reviewing this PR!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant