CVE-2026-45363: `jwt` (Ruby gem) - empty-key HMAC bypass
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(verificationkey: "", ...) -> OpenSSL::HMAC.digest('SHA256', "", signinginput) == signature
The same path is reached when a keyfinder block or keyfinder: argument returns "", nil, or an array containing nil for an unknown key. JWT::Decode#findkey only rejects literal nil and empty arrays, and JWT::JWA::Hmac silently coerces nil to "" (signingkey ||= '') before signing.
JWT.decode(token, nil, true, algorithms: ['HS256']) { |h| "" } -> findkey returns "" # "" && !Array("").empty? == true -> JWA::Hmac.verify(verificationkey: "", ...) -> verifies Common application patterns that produce the unsafe value: redis.get("kid:#{kid}").tos, 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 enforcehmackeylength 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#verifysignature!(keyfinder:)
Other sources
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 keyfinder: 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#verifysignature!. This issue is fixed in versions 2.10.3 and 3.2.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rubygems/jwtto a version that resolves this vulnerability.Fixed in 3.2.0 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 1.0.0-3ubuntu0.1~esm1 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 1.5.6-1ubuntu0.1~esm1 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 2.1.0-2ubuntu0.1~esm1 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 2.2.2-1ubuntu0.1~esm1 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 2.7.1-1+deb13u1build0.24.04.1 - Upgrade
Upgrade
ubuntu/ruby-jwtto a version that resolves this vulnerability.Fixed in 2.7.1-1+deb13u1build0.26.04.1 - Upgrade
Upgrade
jwtto a version that resolves this vulnerability.Fixed in 2.10.3 - Upgrade
Upgrade
jwtto a version that resolves this vulnerability.Fixed in 3.2.0 - Configuration
Set `enforce_hmac_key_length` to true to block empty-key HMAC verification (the option defaults to false, and empty-key bypass is described for `JWT.decode(token, '', true, algorithm: 'HS256')`).
jwt (Ruby gem) enforce_hmac_key_length = false
Event History
Frequently Asked Questions
What is the severity of CVE-2026-45363?
CVE-2026-45363 is a high-severity vulnerability that allows attackers to decode and forge JSON Web Tokens without a valid key.
How do I fix CVE-2026-45363?
To fix CVE-2026-45363, upgrade the 'jwt' package to version 3.2.0 or later.
What type of attack does CVE-2026-45363 allow?
CVE-2026-45363 allows an attacker to forge and potentially manipulate JWT tokens by using an empty key.
Which versions of the 'jwt' package are affected by CVE-2026-45363?
CVE-2026-45363 affects all versions of the 'jwt' package prior to 3.2.0.
Is there any additional mitigation for CVE-2026-45363 beyond updating?
Beyond updating to version 3.2.0, ensure that tokens are always signed with a strong, non-empty key.