!50 [sync] PR-46: fix CVE-2023-23931
From: @openeuler-sync-bot Reviewed-by: @gaoruoshu Signed-off-by: @gaoruoshu
This commit is contained in:
commit
2dd6f8f70b
45
backport-CVE-2023-23931.patch
Normal file
45
backport-CVE-2023-23931.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 9fbf84efc861668755ab645530ec7be9cf3c6696 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Gaynor <alex.gaynor@gmail.com>
|
||||
Date: Tue, 7 Feb 2023 11:34:18 -0500
|
||||
Subject: [PATCH] Don't allow update_into to mutate immutable objects (#8230)
|
||||
|
||||
---
|
||||
src/cryptography/hazmat/backends/openssl/ciphers.py | 2 +-
|
||||
tests/hazmat/primitives/test_ciphers.py | 8 ++++++++
|
||||
2 files changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py
|
||||
index ad5dad3..020ca25 100644
|
||||
--- a/src/cryptography/hazmat/backends/openssl/ciphers.py
|
||||
+++ b/src/cryptography/hazmat/backends/openssl/ciphers.py
|
||||
@@ -135,7 +135,7 @@ class _CipherContext(object):
|
||||
data_processed = 0
|
||||
total_out = 0
|
||||
outlen = self._backend._ffi.new("int *")
|
||||
- baseoutbuf = self._backend._ffi.from_buffer(buf)
|
||||
+ baseoutbuf = self._backend._ffi.from_buffer(buf, require_writable=True)
|
||||
baseinbuf = self._backend._ffi.from_buffer(data)
|
||||
|
||||
while data_processed != total_data_len:
|
||||
diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py
|
||||
index a9219fe..d5410a6 100644
|
||||
--- a/tests/hazmat/primitives/test_ciphers.py
|
||||
+++ b/tests/hazmat/primitives/test_ciphers.py
|
||||
@@ -310,6 +310,14 @@ class TestCipherUpdateInto(object):
|
||||
with pytest.raises(ValueError):
|
||||
encryptor.update_into(b"testing", buf)
|
||||
|
||||
+ def test_update_into_immutable(self, backend):
|
||||
+ key = b"\x00" * 16
|
||||
+ c = ciphers.Cipher(AES(key), modes.ECB(), backend)
|
||||
+ encryptor = c.encryptor()
|
||||
+ buf = b"\x00" * 32
|
||||
+ with pytest.raises((TypeError, BufferError)):
|
||||
+ encryptor.update_into(b"testing", buf)
|
||||
+
|
||||
@pytest.mark.supported(
|
||||
only_if=lambda backend: backend.cipher_supported(
|
||||
AES(b"\x00" * 16), modes.GCM(b"\x00" * 12)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
%global srcname cryptography
|
||||
Name: python-%{srcname}
|
||||
Version: 3.3.1
|
||||
Release: 2
|
||||
Release: 3
|
||||
Summary: PyCA's cryptography library
|
||||
License: ASL 2.0 or BSD
|
||||
URL: https://cryptography.io/en/latest/
|
||||
@ -12,6 +12,7 @@ Source0: https://pypi.io/packages/source/c/cryptography/cryptography-%{ve
|
||||
Patch6000: backport-CVE-2020-36242.patch
|
||||
Patch6001: backport-add-SM4-symmetric-block-cipher-5834.patch
|
||||
Patch6002: backport-provide-openssl-apis-related-to-SM-for-python.patch
|
||||
Patch6003: backport-CVE-2023-23931.patch
|
||||
|
||||
BuildRequires: openssl-devel
|
||||
BuildRequires: gcc
|
||||
@ -121,6 +122,12 @@ PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} -m pytest -k "not (test_
|
||||
%doc README.rst docs
|
||||
|
||||
%changelog
|
||||
* Tue Feb 14 2023 zhuofeng<zhuofeng2@huawei.com> - 3.3.1-3
|
||||
- Type:CVE
|
||||
- CVE:CVE-2023-23931
|
||||
- SUG:NA
|
||||
- DESC:fix CVE-2023-23931
|
||||
|
||||
* Thu Sep 1 2022 dongyuzhen <dongyuzhen@h-partners.com> - 3.3.1-2
|
||||
- add SM4 symmetric block cipher and provide openssl apis related to SM for python
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user