The vulnerability is CWE-400 (Uncontrolled Resource Consumption) in joserfc's JWE General JSON Serialization decryption path. The root cause is that the library validated and capped several structural elements of a JWE (protected header size, encrypted key size, IV size, ciphertext size, auth-tag size) but performed no validation on the number of entries in the recipients array.
The fix commit d6dc8df6c7609277e741069d3733e43996c1cd17 (released in 1.7.5) addresses this in three ways:
- Adds a
max_recipients field (default 16) to JWERegistry and a validate_recipient_count() method in registry.py.
- Calls
registry.validate_recipient_count(recipients) in extract_general_json() (json.py) before iterating over the recipients array.
- Adds an early-exit
break in _perform_decrypt() (message.py) so that when verify_all_recipients=False, decryption stops after the first successful recipient instead of attempting every recipient's decrypt_cek().
The vulnerable functions (present in the vulnerable version < 1.7.5) are:
decrypt_json() (jwe.py) — the public entry point accepting attacker-controlled JWE JSON.
extract_general_json() (json.py) — iterates over the unbounded recipients array with no count cap.
_perform_decrypt() (message.py) — loops over every recipient and calls decrypt_recipient() unconditionally, before verify_all_recipients is consulted.
decrypt_recipient() (message.py) — dispatches to the per-recipient key decryption.
RSAAlgKeyEncryption.decrypt_cek() (jwe_algs.py) — the sink performing the actual RSA private-key decryption per recipient.
These are Python functions, so per the profiler rules, they are reported without module/namespace paths (Python profilers show Class.function_name or function_name).