diff options
author | Narpat Mali <narpat.mali@windriver.com> | 2023-05-05 16:53:53 +0000 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-05-10 04:19:56 -1000 |
commit | 1367249c996394668eaf97404874d7d13225a53d (patch) | |
tree | 4bf457fa9a3d84438877cac462a44bef4bfc9986 | |
parent | 5ffa1afb932bc924acecc19bbad00d8a3d8e6be3 (diff) | |
download | poky-1367249c996394668eaf97404874d7d13225a53d.tar.gz |
python3-cryptography: fix for CVE-2023-23931
cryptography is a package designed to expose cryptographic primitives
and recipes to Python developers. In affected versions `Cipher.update_into`
would accept Python objects which implement the buffer protocol, but
provide only immutable buffers. This would allow immutable objects
(such as `bytes`) to be mutated, thus violating fundamental rules of
Python and resulting in corrupted output. This now correctly raises
an exception. This issue has been present since `update_into` was
originally introduced in cryptography 1.8.
(From OE-Core rev: 368e450c2d800790a05924519f34c579e28e9cbb)
Signed-off-by: Narpat Mali <narpat.mali@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-devtools/python/python3-cryptography/CVE-2023-23931.patch | 49 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python3-cryptography_36.0.2.bb | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-cryptography/CVE-2023-23931.patch b/meta/recipes-devtools/python/python3-cryptography/CVE-2023-23931.patch new file mode 100644 index 0000000000..5fc4878978 --- /dev/null +++ b/meta/recipes-devtools/python/python3-cryptography/CVE-2023-23931.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | From 9fbf84efc861668755ab645530ec7be9cf3c6696 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alex Gaynor <alex.gaynor@gmail.com> | ||
3 | Date: Tue, 7 Feb 2023 11:34:18 -0500 | ||
4 | Subject: [PATCH] Don't allow update_into to mutate immutable objects (#8230) | ||
5 | |||
6 | CVE: CVE-2023-23931 | ||
7 | |||
8 | Upstream-Status: Backport [https://github.com/pyca/cryptography/commit/9fbf84efc861668755ab645530ec7be9cf3c6696] | ||
9 | |||
10 | Signed-off-by: Narpat Mali <narpat.mali@windriver.com> | ||
11 | --- | ||
12 | src/cryptography/hazmat/backends/openssl/ciphers.py | 2 +- | ||
13 | tests/hazmat/primitives/test_ciphers.py | 8 ++++++++ | ||
14 | 2 files changed, 9 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py | ||
17 | index 286583f93..075d68fb9 100644 | ||
18 | --- a/src/cryptography/hazmat/backends/openssl/ciphers.py | ||
19 | +++ b/src/cryptography/hazmat/backends/openssl/ciphers.py | ||
20 | @@ -156,7 +156,7 @@ class _CipherContext: | ||
21 | data_processed = 0 | ||
22 | total_out = 0 | ||
23 | outlen = self._backend._ffi.new("int *") | ||
24 | - baseoutbuf = self._backend._ffi.from_buffer(buf) | ||
25 | + baseoutbuf = self._backend._ffi.from_buffer(buf, require_writable=True) | ||
26 | baseinbuf = self._backend._ffi.from_buffer(data) | ||
27 | |||
28 | while data_processed != total_data_len: | ||
29 | diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py | ||
30 | index 02127dd9c..bf3b047de 100644 | ||
31 | --- a/tests/hazmat/primitives/test_ciphers.py | ||
32 | +++ b/tests/hazmat/primitives/test_ciphers.py | ||
33 | @@ -318,6 +318,14 @@ class TestCipherUpdateInto: | ||
34 | with pytest.raises(ValueError): | ||
35 | encryptor.update_into(b"testing", buf) | ||
36 | |||
37 | + def test_update_into_immutable(self, backend): | ||
38 | + key = b"\x00" * 16 | ||
39 | + c = ciphers.Cipher(AES(key), modes.ECB(), backend) | ||
40 | + encryptor = c.encryptor() | ||
41 | + buf = b"\x00" * 32 | ||
42 | + with pytest.raises((TypeError, BufferError)): | ||
43 | + encryptor.update_into(b"testing", buf) | ||
44 | + | ||
45 | @pytest.mark.supported( | ||
46 | only_if=lambda backend: backend.cipher_supported( | ||
47 | AES(b"\x00" * 16), modes.GCM(b"\x00" * 12) | ||
48 | -- | ||
49 | 2.40.0 | ||
diff --git a/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb b/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb index 9ef5ff39c8..c3ae0c1ab9 100644 --- a/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb +++ b/meta/recipes-devtools/python/python3-cryptography_36.0.2.bb | |||
@@ -17,6 +17,7 @@ SRC_URI += " \ | |||
17 | file://0001-Cargo.toml-specify-pem-version.patch \ | 17 | file://0001-Cargo.toml-specify-pem-version.patch \ |
18 | file://0002-Cargo.toml-edition-2018-2021.patch \ | 18 | file://0002-Cargo.toml-edition-2018-2021.patch \ |
19 | file://fix-leak-metric.patch \ | 19 | file://fix-leak-metric.patch \ |
20 | file://CVE-2023-23931.patch \ | ||
20 | " | 21 | " |
21 | 22 | ||
22 | inherit pypi python_setuptools3_rust | 23 | inherit pypi python_setuptools3_rust |