Advisory Database
  • Advisories
  • Dependency Scanning
  1. golang
  2. ›
  3. github.com/dhax/go-base
  4. ›
  5. CVE-2026-48031

CVE-2026-48031: Go Restful API Boilerplate: Hardcoded JWT Secret "random" Allows Token Forgery

June 10, 2026

The JWT signing secret is hardcoded to the string "random" in two independent locations:

  1. dev.env:10 — The template .env file sets AUTH_JWT_SECRET=random. Every developer who copies this template gets the same default.

  2. cmd/serve.go:35 — viper.SetDefault("auth_jwt_secret", "random") provides a programmatic fallback. Even if the .env file is missing entirely, the application silently starts with "random" as the signing key.

The original code contained a mitigation in auth/jwt/tokenauth.go:22-25 that checked if the secret equaled "random" and replaced it with a randomly-generated 32-byte string. This mitigation had two fatal flaws:

  • (a) Single-value check: Only the exact string "random" was caught. Any other weak secret (e.g., "secret", "changeme", empty string) passed through unchecked.
  • (b) Non-persistent replacement: The auto-generated key was stored only in memory (randStringBytes(32)), not persisted. On every restart, all existing tokens became invalid without warning, breaking all active user sessions. This made the “fix” itself a denial-of-service.

An attacker who reads the public repository knows the signing key is "random". They can forge JWT tokens for arbitrary users (including admin roles), gaining complete authentication bypass on all protected API endpoints.

References

  • github.com/advisories/GHSA-mqq6-462x-jxmm
  • github.com/dhax/go-base/commit/cc82b9740fa6b08e0fad409cd4b418e240dd0e00
  • github.com/dhax/go-base/security/advisories/GHSA-mqq6-462x-jxmm
  • nvd.nist.gov/vuln/detail/CVE-2026-48031

Code Behaviors & Features

Detect and mitigate CVE-2026-48031 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 0.0.0-20260517152733-cc82b9740fa6

Fixed versions

  • 0.0.0-20260517152733-cc82b9740fa6

Solution

Upgrade to version 0.0.0-20260517152733-cc82b9740fa6 or above.

Impact 9.1 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Learn more about CVSS

Weakness

  • CWE-798: Use of Hard-coded Credentials

Source file

go/github.com/dhax/go-base/CVE-2026-48031.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Tue, 23 Jun 2026 12:24:29 +0000.