CVE-2026-45363
JSON

9.1critical

`jwt` (Ruby gem) - empty-key HMAC bypass

Severity
9.1critical CVSS:3.1 by GitHub_M
Exploit likelihood
0.27% (higher than 21% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-c32j-vqhx-rx3x

Description

ruby-jwt is a Ruby implementation of the RFC 7519 OAuth JSON Web Token standard. Prior to 2.10.3 and 3.2.0, JWT.decode(token, '', true, algorithm: 'HS256') accepts an attacker-forged token because OpenSSL::HMAC.digest('SHA256', '', payload) returns a valid digest under an empty key and no empty-key precondition exists in the HMAC algorithm. The same path is reached when a keyfinder block or key_finder: argument returns an empty string, nil, or an array containing nil for an unknown key, affecting HS256, HS384, and HS512 verification through JWT.decode and JWT::EncodedToken#verify_signature!. This issue is fixed in versions 2.10.3 and 3.2.0.

Affected

Product or packageVersionsReported by
jwt ruby-jwt< 2.10.3, >= 3.0.0, < 3.2.0CVE List
jwt (RubyGems)from 3.0.0 before 3.2.0, before 2.10.3GitHub Advisory Database

All scores

GitHub_M9.1critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
GitHub7.4high CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N

Classification

CWE-287CWE-326CWE-1391

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.

What each source says

CVE List

ruby-jwt is a Ruby implementation of the RFC 7519 OAuth JSON Web Token standard. Prior to 2.10.3 and 3.2.0, JWT.decode(token, '', true, algorithm: 'HS256') accepts an attacker-forged token because OpenSSL::HMAC.digest('SHA256', '', payload) returns a valid digest under an empty key and no empty-key precondition exists in the HMAC algorithm. The same path is reached when a keyfinder block or key_finder: argument returns an empty string, nil, or an array containing nil for an unknown key, affecting HS256, HS384, and HS512 verification through JWT.decode and JWT::EncodedToken#verify_signature!. This issue is fixed in versions 2.10.3 and 3.2.0.

GitHub Advisory Database

JWT.decode(token, '', true, algorithm: 'HS256') accepts an attacker-forged token. OpenSSL::HMAC.digest('SHA256', '', payload) returns a valid digest under an empty key, and no raise InvalidKeyError if key.empty? precondition exists in the HMAC algorithm.

JWT.decode(token, "", true, algorithm: 'HS256')
  -> JWA::Hmac.verify(verification_key: "", ...)
  -> OpenSSL::HMAC.digest('SHA256', "", signing_input) == signature

The same path is reached when a keyfinder block or key_finder: argument returns "", nil, or an array containing nil for an unknown key. JWT::Decode#find_key only rejects literal nil and empty arrays, and JWT::JWA::Hmac silently coerces nil to "" (signing_key ||= '') before signing.

JWT.decode(token, nil, true, algorithms: ['HS256']) { |_h| "" }
  -> find_key returns ""               # "" && !Array("").empty? == true
  -> JWA::Hmac.verify(verification_key: "", ...)
  -> verifies

Common application patterns that produce the unsafe value: redis.get("kid:#{kid}").to_s, ORM string columns with default: '', ENV['SECRET'] || '', Hash.new('') lookups, [primary, fallback] where fallback may be nil. Applications passing a non-empty static key:, or whose keyfinder returns nil / raises on miss, are not affected.

The existing enforce_hmac_key_length option would block this but defaults to false. On OpenSSL ≥ 3.5 the empty-key HMAC.digest call no longer raises, so the OpenSSL-3.0 rescue in JWA::Hmac#sign does not fire.

Affects HS256/HS384/HS512 via both JWT.decode (positional key and block keyfinder) and JWT::EncodedToken#verify_signature!(key_finder:)

NVD (es)

ruby-jwt es una implementación en Ruby del estándar RFC 7519 OAuth JSON Web Token. Antes de las versiones 2.10.3 y 3.2.0, JWT.decode(token, ’’, true, algorithm: ’HS256’) acepta un token forjado por un atacante porque OpenSSL::HMAC.digest(’SHA256’, ’’, payload) devuelve un digest válido con una clave vacía y no existe ninguna precondición de clave vacía en el algoritmo HMAC. Se alcanza la misma ruta cuando un bloque keyfinder o un argumento key_finder: devuelve una cadena vacía, nil, o un array que contiene nil para una clave desconocida, afectando la verificación de HS256, HS384 y HS512 a través de JWT.decode y JWT::EncodedToken#verify_signature!. Este problema está solucionado en las versiones 2.10.3 y 3.2.0.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-45363 changed 2026-09-19CVE Terms of Use
GitHub Advisory DatabaseGHSA-c32j-vqhx-rx3x changed 2026-09-10CC-BY-4.0
NVDCVE-2026-45363 changed 2026-10-24Public domain