summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2024-03-12 11:32:31 +0530
committerArmin Kuster <akuster808@gmail.com>2024-04-02 08:12:59 -0400
commit830419a2d9dccea49e8507169151d6296b321be8 (patch)
tree03e7354e63b4259729ee56979ccc32d316abd5ce
parent96e447ff9134d1a99e398b2570a50af3a7c6538d (diff)
downloadmeta-openembedded-830419a2d9dccea49e8507169151d6296b321be8.tar.gz
python3-cryptography: fix CVE-2024-26130 NULL pointer dereference
Upstream-Status: Backport from https://github.com/pyca/cryptography/commit/97d231672763cdb5959a3b191e692a362f1b9e55 Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch66
-rw-r--r--meta-python/recipes-devtools/python/python3-cryptography_2.8.bb1
2 files changed, 67 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch b/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch
new file mode 100644
index 000000000..c0acb9066
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-cryptography/CVE-2024-26130.patch
@@ -0,0 +1,66 @@
1From 97d231672763cdb5959a3b191e692a362f1b9e55 Mon Sep 17 00:00:00 2001
2From: Alex Gaynor <alex.gaynor@gmail.com>
3Date: Mon, 19 Feb 2024 11:50:28 -0500
4Subject: [PATCH] Fixes #10422 -- don't crash when a PKCS#12 key and cert don't
5match (#10423)
6
7Upstream-Status: Backport [https://github.com/pyca/cryptography/commit/97d231672763cdb5959a3b191e692a362f1b9e55]
8CVE: CVE-2024-26130
9Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
10---
11 .../hazmat/backends/openssl/backend.py | 9 +++++++++
12 tests/hazmat/primitives/test_pkcs12.py | 18 ++++++++++++++++++
13 2 files changed, 27 insertions(+)
14
15diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
16index 7e9fa20..ce3fc8c 100644
17--- a/src/cryptography/hazmat/backends/openssl/backend.py
18+++ b/src/cryptography/hazmat/backends/openssl/backend.py
19@@ -1046,6 +1046,15 @@ class Backend(object):
20 raise NotImplementedError(
21 'Extension not supported: {}'.format(extension.oid)
22 )
23+ if p12 == self._ffi.NULL:
24+ errors = self._consume_errors()
25+ raise ValueError(
26+ (
27+ "Failed to create PKCS12 (does the key match the "
28+ "certificate?)"
29+ ),
30+ errors,
31+ )
32
33 ext_struct = encode(self, extension.value)
34 nid = self._lib.OBJ_txt2nid(
35diff --git a/tests/hazmat/primitives/test_pkcs12.py b/tests/hazmat/primitives/test_pkcs12.py
36index f084d57..c4160b0 100644
37--- a/tests/hazmat/primitives/test_pkcs12.py
38+++ b/tests/hazmat/primitives/test_pkcs12.py
39@@ -17,6 +17,24 @@ from cryptography.hazmat.primitives.serialization.pkcs12 import (
40
41 from .utils import load_vectors_from_file
42
43+ @pytest.mark.supported(
44+ only_if=lambda backend: backend._lib.Cryptography_HAS_PKCS12_SET_MAC,
45+ skip_message="Requires OpenSSL with PKCS12_set_mac",
46+ )
47+ def test_set_mac_key_certificate_mismatch(self, backend):
48+ cacert, _ = _load_ca(backend)
49+ key = ec.generate_private_key(ec.SECP256R1())
50+ encryption = (
51+ serialization.PrivateFormat.PKCS12.encryption_builder()
52+ .hmac_hash(hashes.SHA256())
53+ .build(b"password")
54+ )
55+
56+ with pytest.raises(ValueError):
57+ serialize_key_and_certificates(
58+ b"name", key, cacert, [], encryption
59+ )
60+
61
62 @pytest.mark.requires_backend_interface(interface=DERSerializationBackend)
63 class TestPKCS12(object):
64--
652.25.1
66
diff --git a/meta-python/recipes-devtools/python/python3-cryptography_2.8.bb b/meta-python/recipes-devtools/python/python3-cryptography_2.8.bb
index e4d69fa5a..63bc0e0d6 100644
--- a/meta-python/recipes-devtools/python/python3-cryptography_2.8.bb
+++ b/meta-python/recipes-devtools/python/python3-cryptography_2.8.bb
@@ -15,6 +15,7 @@ SRC_URI += " \
15 file://0002-chunking-didn-t-actually-work-5499.patch \ 15 file://0002-chunking-didn-t-actually-work-5499.patch \
16 file://0003-correct-buffer-overflows-cause-by-integer-overflow-i.patch \ 16 file://0003-correct-buffer-overflows-cause-by-integer-overflow-i.patch \
17 file://CVE-2023-23931.patch \ 17 file://CVE-2023-23931.patch \
18 file://CVE-2024-26130.patch \
18" 19"
19 20
20inherit pypi setuptools3 21inherit pypi setuptools3