
Cloud Vulnerability DB
A community-led vulnerabilities database
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.
jwe: RSA1_5 unwrap errors escape before content authentication| Field | Value |
|---|---|
| Package | jwe (RubyGems, pkg:gem/jwe) |
| Repository | https://github.com/jwt/ruby-jwe |
| Component | JWE::Alg::Rsa15#decrypt |
| Vulnerability class | PKCS#1 v1.5 padding oracle |
| CWE | CWE-203 |
| Severity (reporter assessment) | High |
| Verified against | jwe 1.1.1 and commit 608da6e5e5f7b7851d5a412925677393d3c34128 |
| API surface | Public documented API: JWE.decrypt |
| Affected in default configuration | No — RSA1_5 is supported but is not the encryption default; the default algorithm name was not verified |
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.
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.
JWE.decrypt API.README.md:97) but is not the encryption default; the exact default and its source line were not verified.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.enc_key by Serialization::Compact.decode (lib/jwe/serialization/compact.rb:12-18).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).Rsa15#decrypt performs key.private_decrypt(encrypted_cek) without rescue or random-CEK substitution (lib/jwe/alg/rsa15.rb:17-18).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.lib/jwe/alg/rsa15.rb, lines 17-18 at 608da6e5e5f7b7851d5a412925677393d3c34128:
def decrypt(encrypted_cek)
key.private_decrypt(encrypted_cek) # Sink: RSA unwrap failure escapes
endVerified 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
endOpenSSL::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.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.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.plaintextAlternatively, disable RSA1_5 unless a caller explicitly opts in, while retaining implicit rejection for callers that require compatibility. Notes:
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.Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."