CVE-2026-48031: Go Restful API Boilerplate: Hardcoded JWT Secret "random" Allows Token Forgery
The JWT signing secret is hardcoded to the string "random" in two independent locations:
dev.env:10— The template.envfile setsAUTH_JWT_SECRET=random. Every developer who copies this template gets the same default.cmd/serve.go:35—viper.SetDefault("auth_jwt_secret", "random")provides a programmatic fallback. Even if the.envfile 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
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 →