diff --git a/.python-jwcrypto.metadata b/.python-jwcrypto.metadata new file mode 100644 index 0000000..e035eeb --- /dev/null +++ b/.python-jwcrypto.metadata @@ -0,0 +1,2 @@ +26271eca1d3fd41cbbfaf3f938d2f1491d6cce69 jwcrypto-0.6.0.tar.gz +038ee5faf896548477c0b57c3cacb92add36e550 jwcrypto-0.8.tar.gz diff --git a/0001-Address-potential-DoS-with-high-compression-ratio_rhel#28698.patch b/0001-Address-potential-DoS-with-high-compression-ratio_rhel#28698.patch new file mode 100644 index 0000000..78f786d --- /dev/null +++ b/0001-Address-potential-DoS-with-high-compression-ratio_rhel#28698.patch @@ -0,0 +1,74 @@ +From 90477a3b6e73da69740e00b8161f53fea19b831f Mon Sep 17 00:00:00 2001 +From: Simo Sorce +Date: Tue, 5 Mar 2024 16:57:17 -0500 +Subject: [PATCH] Address potential DoS with high compression ratio + +Fixes CVE-2024-28102 + +Signed-off-by: Simo Sorce +--- + jwcrypto/jwe.py | 7 +++++++ + jwcrypto/tests.py | 26 ++++++++++++++++++++++++++ + 2 files changed, 33 insertions(+) + +diff --git a/jwcrypto/jwe.py b/jwcrypto/jwe.py +index 9412881..5df500b 100644 +--- a/jwcrypto/jwe.py ++++ b/jwcrypto/jwe.py +@@ -10,5 +10,8 @@ + from jwcrypto.jwa import JWA + ++# Limit the amount of data we are willing to decompress by default. ++default_max_compressed_size = 256 * 1024 ++ + + # RFC 7516 - 4.1 + # name: (description, supported?) +@@ -387,6 +387,10 @@ def _decrypt(self, key, ppe): + + compress = jh.get('zip', None) + if compress == 'DEF': ++ if len(data) > default_max_compressed_size: ++ raise InvalidJWEData( ++ 'Compressed data exceeds maximum allowed' ++ 'size' + f' ({default_max_compressed_size})') + self.plaintext = zlib.decompress(data, -zlib.MAX_WBITS) + elif compress is None: + self.plaintext = data +diff --git a/jwcrypto/tests.py b/jwcrypto/tests.py +index bb2ff10..59049f8 100644 +--- a/jwcrypto/tests.py ++++ b/jwcrypto/tests.py +@@ -1526,6 +1526,32 @@ def test_pbes2_hs256_aeskw_custom_params(self): + token.deserialize(jwt=e) + json_decode(token.claims) + ++ def test_jwe_decompression_max(self): ++ key = jwk.JWK(kty='oct', k=base64url_encode(b'A' * (128 // 8))) ++ payload = '{"u": "' + "u" * 400000000 + '", "uu":"' \ ++ + "u" * 400000000 + '"}' ++ protected_header = { ++ "alg": "A128KW", ++ "enc": "A128GCM", ++ "typ": "JWE", ++ "zip": "DEF", ++ } ++ enc = jwe.JWE(payload.encode('utf-8'), ++ recipient=key, ++ protected=protected_header).serialize(compact=True) ++ with self.assertRaises(jwe.InvalidJWEData): ++ check = jwe.JWE() ++ check.deserialize(enc) ++ check.decrypt(key) ++ ++ defmax = jwe.default_max_compressed_size ++ jwe.default_max_compressed_size = 1000000000 ++ # ensure we can eraise the limit and decrypt ++ check = jwe.JWE() ++ check.deserialize(enc) ++ check.decrypt(key) ++ jwe.default_max_compressed_size = defmax ++ + + class JWATests(unittest.TestCase): + def test_jwa_create(self): diff --git a/python-jwcrypto.spec b/python-jwcrypto.spec index b02b74e..9f4156a 100644 --- a/python-jwcrypto.spec +++ b/python-jwcrypto.spec @@ -16,13 +16,15 @@ Name: python-%{srcname} Version: 0.8 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Implements JWK, JWS, JWE specifications using python-cryptography License: LGPLv3+ URL: https://github.com/latchset/%{srcname} Source0: https://github.com/latchset/%{srcname}/releases/download/v%{version}/%{srcname}-%{version}.tar.gz +Patch1: 0001-Address-potential-DoS-with-high-compression-ratio_rhel#28698.patch + BuildArch: noarch %if 0%{?with_python2} BuildRequires: python2-devel @@ -67,6 +69,7 @@ Implements JWK, JWS, JWE specifications using python-cryptography %prep %setup -q -n %{srcname}-%{version} +%autopatch -p 1 %build %if 0%{?with_python2} @@ -122,6 +125,10 @@ rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/__pycache__/tests{,-cookbook}.* %changelog +* Thu Apr 04 2024 Rafael Jeffman - 0.8-5 +- Address potential DoS with high compression ratio + Resolves: RHEL-28698 + * Tue Aug 10 2021 Mohan Boddu - 0.8-4 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688