
Cloud Vulnerability DB
A community-led vulnerabilities database
= 1.0.0, < 1.9.7, and 1.10.0b1. Fixed in 1.9.7.
authlib.jose.JsonWebEncryption.deserialize_json() (and deserialize(), which sends any {...} input to it) accepts a JWE General JSON Serialization with any number of entries in recipients. When no recipient kid matches the decryption key, it tries the private key against every entry in turn and drops each failure. Every attempt is a full private-key operation (an RSA private decryption for RSA-OAEP, or ECDH plus key derivation for ECDH-ES+KW). An unauthenticated sender needs no key material: one message of about 1.4 MiB with 4000 random encrypted_key values costs the server about 2.4 s of CPU with RSA-2048. A valid message costs about 1 ms. RSA-4096 costs about 3.5 times as much.
This is the same issue as joserfc GHSA-jpxq-7h8p-2q76 (CVE-2026-119283), which joserfc 1.7.5 fixed by capping the count (JWERegistry.max_recipients = 16). Authlib's own authlib.jose JWE implementation did not get that fix. It is still unbounded in 1.9.6 and on main (1.10.0b1).
File authlib/jose/rfc7516/jwe.py, tag v1.9.6:
deserialize(): a dict, or a str/bytes value that starts with { and ends with }, goes to deserialize_json(). An application that calls deserialize() and expects compact tokens is therefore also exposed.recipients = obj["recipients"]: the length of the attacker-supplied list is never checked. Each entry's encrypted_key is base64-decoded (L537-540). The existing segment-size limit applies to each entry separately, so it does not limit the number of entries._unwrap_for_matching_recipient(): if the key's kid (or the kid in a (kid, key) tuple) matches a recipient header, only that entry is tried. Otherwise the loop at L601 calls unwrap_func(), which is alg.unwrap() and so a private-key operation, for every recipient, and catches Exception at L605 to continue. The attacker controls the recipient headers and simply leaves out kid, so giving the key a kid or passing a (kid, key) tuple does not help. With 2000 recipients and no kid in the message, the call takes about 0.9 s whether the key is given as a key with a kid, as a (kid, key) tuple, or without a kid.alg from the protected/unprotected header. The default JsonWebEncryption() allows RSA-OAEP, RSA-OAEP-256, ECDH-ES+A*KW and the others, so no special configuration is needed. With EC keys every entry can carry its own epk, so each entry costs point validation, ECDH, Concat KDF and AES key unwrap (3000 entries take about 0.4 s on P-256 and about 1.4 s on P-521).
The cost grows linearly with the request size, at about 1.7 s of CPU per MiB with RSA-2048 and about 5.4 s per MiB with RSA-4096. The work holds the GIL, so it blocks the whole Python worker process. A request body limit such as Django's default 2.5 MB (DATA_UPLOAD_MAX_MEMORY_SIZE) still allows about 4 s (RSA-2048) or about 13 s (RSA-4096) of CPU per request. Flask/Werkzeug and Starlette have no default limit on the size of a JSON body.
Suggested fix: before any unwrap, reject recipients lists longer than a small configurable maximum, as joserfc 1.7.5 does with max_recipients = 16, and raise a JoseError subclass. Also consider stopping at the first failed unwrap when the key has a kid and no recipient matched it, and adding a similar cap on the signatures array in JsonWebSignature.deserialize_json(), which also processes every entry with no limit.python3 -m venv venv && . venv/bin/activate
pip install authlib==1.9.6poc.py:
import os
import time
import authlib
from authlib.common.encoding import urlsafe_b64encode
from authlib.jose import JsonWebEncryption
from authlib.jose import RSAKey
key = RSAKey.generate_key(2048, is_private=True)
jwe = JsonWebEncryption()
header = {"protected": {"alg": "RSA-OAEP", "enc": "A128GCM"}}
valid = jwe.serialize_json(header, b"hello", key)
start = time.perf_counter()
jwe.deserialize_json(valid, key)
print(f"authlib {authlib.__version__}")
print(f"valid message, 1 recipient: {time.perf_counter() - start:.3f}s")
# No key material needed: random encrypted keys, no kid.
forged = dict(valid)
forged["recipients"] = [
{"encrypted_key": urlsafe_b64encode(os.urandom(256)).decode()}
for _ in range(4000)
]
start = time.perf_counter()
try:
jwe.deserialize_json(forged, key)
except Exception as exc:
print(f"forged message, 4000 recipients: {exc!r}", end=" ")
print(f"after {time.perf_counter() - start:.3f}s")Output with authlib 1.9.6:
authlib 1.9.6
valid message, 1 recipient: 0.001s
forged message, 4000 recipients: ValueError('Decryption failed') after 2.209sOutput with authlib 1.9.7:
authlib 1.9.7
valid message, 1 recipient: 0.001s
forged message, 4000 recipients: ValueError('Too many recipients.') after 0.004sDenial of service through CPU exhaustion. Any application that decrypts JWE received from untrusted parties with JsonWebEncryption.deserialize_json() or JsonWebEncryption.deserialize() and an RSA (or EC) private key is affected. Examples are endpoints that accept encrypted messages or tokens, and messaging protocols built on JWE JSON with several recipients. The attacker needs no credentials and no key material, and does not need the recipient's public key. The attack works with the default JsonWebEncryption() configuration. Each request makes the server perform as many private-key operations as the attacker chooses, limited only by the request size (more than 1000 times the cost of a valid message for each MiB sent). The work holds the GIL, so a few concurrent requests stall the worker processes. No confidentiality or integrity impact. jwt.decode() and deserialize_compact() are not affected.
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."