Insecure JSON Web Token (Weak Signing Secret)

  • CWE 326
  • OWASP 2025-A04
  • OWASP 2025-A07

The token is signed with an HMAC algorithm (HS256, HS384 or HS512) and the secret that was used is a well known or easily guessable value, such as a word from a tutorial, a default configuration or the name of the site. Rapplex recovered the secret by checking the token against a list of common secrets, without contacting the server.

Knowing the secret allows anybody to sign tokens of their own. They can impersonate any user, including administrators, and change roles and permissions at will. The attack runs offline and cannot be detected or rate limited by the server.

Remediation
  1. Replace the secret immediately with a random value of at least 256 bits generated by a cryptographically secure generator.

  2. Invalidate every token that was signed with the old secret. All of them must be considered forged.

  3. Store the secret outside the code base, in a secret manager or in protected server configuration, and never reuse it between environments.

  4. Consider asymmetric signing (RS256, ES256, EdDSA) so that services that only verify tokens never hold a key that can sign them.

References