Insecure JSON Web Token (Untrusted Key Reference)

  • CWE 347
  • OWASP 2025-A04
  • OWASP 2025-A07

The header of the token contains a parameter that influences which key is used to verify it: jku (URL of a key set), x5u (URL of a certificate), jwk (a key embedded in the token), or a kid (key identifier) value with path or query characters in it.

When the verifier follows these values blindly, an attacker can make it fetch the verification key from a server under their control, accept a key that they embedded, or steer a file or database lookup with the key identifier (path traversal, SQL injection), and then sign tokens with the matching private key.

Rapplex only reports the presence of the parameter, since the behavior of the verifier cannot be told from a token alone. It is worth testing whether the server follows it.

Remediation
  1. Ignore jku, x5u and jwk unless the value matches a strict allow-list that is configured on the server.

  2. Look keys up by kid in a fixed set and treat the value as data. Never use it to build a file path or a query.

  3. Reject tokens whose key reference is not recognized.

References