CVE-2024-29370
Executive Summary
CVE-2024-29370 is a high-severity Denial-of-Service (DoS) vulnerability in the python-jose library, specifically in the jwe.decrypt function of version 3.3.0. The flaw allows an unauthenticated attacker to craft a malicious JSON Web Encryption (JWE) token with an extremely high compression ratio. When the server processes this token, the decompression step causes excessive memory allocation and CPU consumption, leading to a DoS condition. The vulnerability is classified under CWE-409 (Improper Handling of Highly Compressed Data). No official patch has been released as of the latest advisory.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the python-jose PyPI package. Organizations using this library in their Python applications are at risk. Since the package is widely used for JWT/JWE handling in microservices and API gateways, a supply chain attack could propagate the vulnerable component across multiple services. It is critical to audit all dependencies and consider temporary mitigations until a patch is available.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Base Score: 7.5 (High)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: None (PR:N)
- User Interaction: None (UI:N)
- Scope: Unchanged (S:U)
- Confidentiality Impact: None (C:N)
- Integrity Impact: None (I:N)
- Availability Impact: High (A:H)
The threat level is High due to the low attack complexity and the potential for complete service disruption without authentication.
Deep Dive & Mechanics
The vulnerability resides in the jwe.decrypt function of python-jose 3.3.0. When a JWE token is received, the library decrypts the payload and then decompresses it if the zip header parameter is set. The decompression is performed using the zlib library, which does not enforce any limits on the compression ratio. An attacker can craft a JWE token containing a small compressed payload that expands to a massive size upon decompression (e.g., using a "zip bomb" technique). This causes the server to allocate excessive memory and spend significant CPU time on decompression, leading to resource exhaustion and a Denial-of-Service condition.
The attack does not require valid encryption keys, as the token can be crafted with arbitrary content. The vulnerability is triggered during the decryption process before any signature verification (if applicable), making it exploitable by any unauthenticated client.
Vulnerable vs. Patched Code
Vulnerable Code (python-jose 3.3.0):
# In jwe.py, decrypt function
def decrypt(self, token, key, ...):
# ... decryption steps ...
if protected.get('zip') == 'DEF':
plaintext = zlib.decompress(plaintext)
return plaintext
Patched Code (Hypothetical fix):
import zlib
MAX_DECOMPRESSED_SIZE = 10 * 1024 * 1024 # 10 MB limit
def decrypt(self, token, key, ...):
# ... decryption steps ...
if protected.get('zip') == 'DEF':
decompressor = zlib.decompressobj()
plaintext = decompressor.decompress(plaintext, MAX_DECOMPRESSED_SIZE)
if decompressor.unconsumed_tail:
raise ValueError("Decompressed data exceeds maximum allowed size")
return plaintext
The patched code introduces a maximum decompressed size limit and checks for unconsumed data, preventing zip bomb attacks.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Craft a malicious JWE token:
- Create a small payload that expands to a large size (e.g., using
zlib.compress(b'A' * 100000000)). - Encrypt it with a random key (the key does not need to be valid for the target).
- Set the
zipheader toDEF. - Send the token to the target endpoint that processes JWE tokens.
- Create a small payload that expands to a large size (e.g., using
Example Python script:
import zlib
import json
from base64 import urlsafe_b64encode
# Create a zip bomb payload
payload = b'A' * 100000000 # 100 MB of data
compressed = zlib.compress(payload)
# Build a minimal JWE token (simplified)
header = {"alg": "dir", "enc": "A128CBC-HS256", "zip": "DEF"}
encoded_header = urlsafe_b64encode(json.dumps(header).encode()).rstrip(b'=').decode()
# ... (encryption steps omitted for brevity)
# The token is sent to the target
- Expected outcome: The server will attempt to decompress the payload, consuming excessive memory and CPU, leading to a DoS.
Blue Team (Defense & Detection)
- Monitor for high memory usage in processes handling JWE tokens.
- Implement rate limiting on endpoints that accept JWE tokens.
- Use a Web Application Firewall (WAF) to inspect and block tokens with suspicious
zipheaders or unusually small payloads. - Apply a temporary patch by monkey-patching the
zlib.decompressfunction to enforce size limits.
Indicators of Compromise (IOCs)
- Network IOCs:
- JWE tokens with
zipheader set toDEFand unusually small encrypted payloads. - High volume of requests to JWE decryption endpoints from a single source.
- JWE tokens with
- System IOCs:
- Sudden spikes in memory and CPU usage on servers processing JWE tokens.
- Application logs showing
MemoryErrororOutOfMemoryErrorexceptions during JWE decryption.
- File IOCs:
- Temporary files created by the decompression process that are abnormally large.
Detection Engineering
YARA Rule
rule CVE_2024_29370_JWE_ZipBomb {
meta:
description = "Detects JWE tokens with potential zip bomb payloads"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-29370"
strings:
$zip_header = "DEF" ascii wide
$jwe_pattern = /eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/
condition:
$jwe_pattern and $zip_header
}
Sigma Rule
title: CVE-2024-29370 - JWE Zip Bomb DoS Attempt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects attempts to exploit CVE-2024-29370 by sending JWE tokens with DEF compression
author: Valters IT
date: 2024-01-01
logsource:
category: application
product: python-jose
detection:
selection:
EventID: 1000 # Example event ID for JWE decryption
TokenHeader|contains: "DEF"
condition: selection
falsepositives:
- Legitimate use of DEF compression with small payloads
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-29370 JWE Zip Bomb Attempt"; flow:to_server; content:"DEF"; http_client_body; pcre:"/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/R"; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Mitigation:
- Disable JWE compression support in
python-joseby monkey-patching thedecryptfunction to reject tokens withzipheader. - Implement a custom decompression wrapper that limits output size.
- Disable JWE compression support in
Long-term Fix:
- Upgrade to a patched version of
python-joseonce available. - Consider switching to a more actively maintained JOSE library (e.g.,
python-jwtorPyJWT).
- Upgrade to a patched version of
Network-Level Protections:
- Deploy a WAF with rules to block JWE tokens containing the
zipheader. - Use rate limiting and anomaly detection to identify DoS attempts.
- Deploy a WAF with rules to block JWE tokens containing the
Monitoring:
- Enable detailed logging for JWE decryption operations.
- Set up alerts for high memory usage or decompression errors.
Valters IT
Senior DevSecOps & Cyber Threat Intelligence Expert