Vulnerability DatabaseGHSA-9hgp-rr8g-x7cq

GHSA-9hgp-rr8g-x7cq: 
Ruby vulnerability analysis and mitigation

Patches

Fixed in jwe 1.1.2. RSA1_5 key decryption now uses implicit rejection: when unwrapping the content encryption key fails or yields a key of the wrong length, a random key of the expected length is used instead, so every invalid token fails content authentication with the same JWE::InvalidData error. Users who accept RSA1_5 tokens should upgrade, and should consider whether RSA1_5 needs to be accepted at all.

Padding oracle in jwe: RSA1_5 unwrap errors escape before content authentication

Report metadata

FieldValue
Packagejwe (RubyGems, pkg:gem/jwe)
Repositoryhttps://github.com/jwt/ruby-jwe
ComponentJWE::Alg::Rsa15#decrypt
Vulnerability classPKCS#1 v1.5 padding oracle
CWECWE-203
Severity (reporter assessment)High
Verified againstjwe 1.1.1 and commit 608da6e5e5f7b7851d5a412925677393d3c34128
API surfacePublic documented API: JWE.decrypt
Affected in default configurationNo — RSA1_5 is supported but is not the encryption default; the default algorithm name was not verified

Summary

For RSA1_5 key management, JWE::Alg::Rsa15#decrypt passes the attacker-controlled encrypted content-encryption key (CEK) directly to OpenSSL's PKCS#1 v1.5 private-key operation and does not replace failed unwraps with a random CEK. Under pre-OpenSSL-3.2 padding semantics, malformed RSA ciphertexts therefore raise a padding exception before content authentication, while correctly padded CEKs paired with an invalid tag reach authentication and raise JWE::InvalidData. An application that passes attacker-supplied compact JWEs to JWE.decrypt can expose this distinction through exception classes, responses, or timing. Repeated queries can then provide a Bleichenbacher-style validity oracle capable of recovering a captured RSA1_5 CEK and plaintext. The reported affected range is <= 1.1.1; validation found the same defect across the published versions in scope, 0.1.0 through 1.1.1.

Impact

An attacker able to query a recipient that decrypts RSA1_5 JWEs can recover the CEK and plaintext of captured RSA1_5 ciphertexts protected by that recipient key, without obtaining the private key. The same risk applies if the key is reused for other PKCS#1 v1.5 ciphertexts and the application exposes the oracle. Without this behavior, the attacker would have only public-key encryption capability and could not decrypt captured messages. The new capability is adaptive plaintext recovery based on the difference between RSA unwrap failure and later content-authentication failure. No CVSS vector is provided because exploitability depends on the consuming application's RSA1_5 use, observable error or timing behavior, and OpenSSL version. The reporter assessment is High. The full exploit was verified under pre-OpenSSL-3.2 semantics; OpenSSL 3.6.2's implicit-rejection mitigation blocked the tested end-to-end attack, although the gem still exposed a noisy JWE::BadCEK versus JWE::InvalidData distinction. Consumers that accept only OAEP ciphertexts are outside this finding.

Preconditions

  1. A recipient passes compact JWE values from an untrusted sender to the public JWE.decrypt API.
  2. RSA1_5 ciphertexts are accepted under the recipient key. RSA1_5 is documented as available (README.md:97) but is not the encryption default; the exact default and its source line were not verified.
  3. The attacker can make repeated decryption requests and distinguish unwrap failure from content-authentication failure through exception class, message, response status, or sufficient timing signal.
  4. For the verified full exploit, the deployment exposes pre-OpenSSL-3.2 PKCS#1 v1.5 semantics. On the tested OpenSSL 3.6.2 stack, implicit rejection made the remaining signal noisy enough to derail all three attempted Bleichenbacher step-2a trials. No monkey-patching or non-standard library use is required: RSA1_5 is a documented algorithm and JWE.decrypt is a documented entry point. Selecting RSA1_5 is non-default but supported, and the documentation does not warn callers that they must suppress unwrap distinctions.

Data flow

  1. Source — the second segment of an attacker-supplied compact JWE is decoded as enc_key by Serialization::Compact.decode (lib/jwe/serialization/compact.rb:12-18).
  2. Propagation — check_alg accepts RSA1_5, after which Alg.decrypt_cek instantiates Rsa15 and passes the decoded encrypted CEK unchanged (lib/jwe.rb:42-47, lib/jwe/alg.rb:24-25).
  3. Sink — Rsa15#decrypt performs key.private_decrypt(encrypted_cek) without rescue or random-CEK substitution (lib/jwe/alg/rsa15.rb:17-18).
  4. Reachability — a consumer reaches the sink through the documented JWE.decrypt(payload, key) entry point (README.md:26-71). Only a successful RSA unwrap reaches content authentication (lib/jwe.rb:47-49), where invalid tags raise JWE::InvalidData.

Vulnerable code

lib/jwe/alg/rsa15.rb, lines 17-18 at 608da6e5e5f7b7851d5a412925677393d3c34128:

def decrypt(encrypted_cek)
  key.private_decrypt(encrypted_cek) # Sink: RSA unwrap failure escapes
end

Reproduction

Verified dynamically on jwe 1.1.1. The exact Ruby and host operating-system versions were not verified. One run used pre-OpenSSL-3.2 RSA padding semantics by disabling OpenSSL's implicit-rejection behavior at the OpenSSL layer; the gem itself was unchanged. The following minimal differential test creates one token with a malformed encrypted-key segment and another with a valid encrypted-key segment but a modified authentication tag:

require 'jwe'
require 'openssl'
key = OpenSSL::PKey::RSA.generate(2048)
token = JWE.encrypt('secret', key, alg: 'RSA1_5')
parts = token.split('.')
bad_wrap = parts.dup
bad_wrap[1] = JWE::Base64.jwe_encode("\x00" * (key.n.num_bits / 8))
bad_tag = parts.dup
tag = JWE::Base64.jwe_decode(bad_tag[4]).bytes
tag[-1] ^= 1
bad_tag[4] = JWE::Base64.jwe_encode(tag.pack('C*'))
{malformed_wrap: bad_wrap, bad_tag: bad_tag}.each do |name, candidate|
  begin
    JWE.decrypt(candidate.join('.'), key)
  rescue => error
    puts "#{name}: #{error.class}: #{error.message}"
  end
end
  • Expected: Every invalid RSA1_5 token should use a random fallback CEK, continue through content authentication, and return one indistinguishable authentication failure.
  • Actual: Under pre-OpenSSL-3.2 semantics, the malformed wrapped key escaped as OpenSSL::PKey::PKeyError with padding check failed, while the modified tag reached authentication and raised JWE::InvalidData. A separate adaptive test using only the exception class from the public JWE.decrypt API recovered a 32-byte CEK exactly and decrypted the controlled test message in 37,279 oracle queries over 1.8 seconds against a 512-bit test key.
  • Current-stack qualification: With OpenSSL 3.6.2 implicit rejection enabled, 500 of 500 correctly padded 32-byte CEKs produced JWE::InvalidData, while 2,996 of 3,000 malformed values produced JWE::BadCEK because OpenSSL's synthetic output failed the gem's length check. The positive signal was dominated by false positives, and all three attempted full attacks derailed. This mitigation comes from OpenSSL rather than the gem.

Suggested remediation

Implement RSA1_5 implicit rejection in the library: begin with a cryptographically random CEK of the expected length, replace it only after a successful, length-valid unwrap, always continue through content authentication, and expose one uniform failure.


# Illustrative pseudocode; exact project helper names are not verified.
cek = secure_random_bytes(expected_cek_length)
begin
  unwrapped = key.private_decrypt(encrypted_cek)
  cek = unwrapped if unwrapped.bytesize == expected_cek_length
rescue OpenSSL::PKey::PKeyError
  # Keep the random CEK and continue to content authentication.
end
result = authenticate_and_decrypt_with(cek)
raise JWE::InvalidData unless result.authenticated?
result.plaintext

Alternatively, disable RSA1_5 unless a caller explicitly opts in, while retaining implicit rejection for callers that require compatibility. Notes:

  • Do not expose a CEK-length error such as JWE::BadCEK before content authentication; selection of the real or fallback CEK and the outward failure must not disclose unwrap success through error type, response, or timing.
  • Verify the RSA exception hierarchy across every supported Ruby/OpenSSL combination so all unwrap failures take the fallback path.
  • Other key-management algorithms, including OAEP, are outside this finding; no change to those paths is recommended based on the supplied evidence.
  • Other code paths through the same RSA1_5 sink were not verified. Suggested regression test alongside unknown — the existing test file was not identified: submit a malformed encrypted-key segment and, separately, a correctly wrapped CEK with a modified tag, then assert that both reach the same externally visible authentication failure. Include supported older OpenSSL semantics in the compatibility matrix so the test does not rely on OpenSSL 3.2+ implicit rejection.

Source: NVD

Related Ruby vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-7c6x-34q5-4g2jHIGH7.5
  • Ruby logoRuby
  • websocket-driver
NoYesNov 26, 2026
GHSA-548x-44fh-cxv4MEDIUM6.1
  • Ruby logoRuby
  • dandruff
NoYesNov 26, 2026
GHSA-477m-5qf8-pjv6MEDIUM5.9
  • Ruby logoRuby
  • faye-websocket
NoYesNov 26, 2026
GHSA-qwvx-w3vv-2r28LOWN/A
  • Ruby logoRuby
  • jwe
NoYesNov 26, 2026
GHSA-9hgp-rr8g-x7cqHIGHN/A
  • Ruby logoRuby
  • jwe
NoYesNov 26, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management