Skip to content

Commit d6951dc

Browse files
reaperhulkalex
andauthoredFeb 7, 2023
changelog + security fix backport (#8231)
* Don't allow update_into to mutate immutable objects (#8230) * add changelog for 39.0.1 * oops * bump versions * remove circle --------- Co-authored-by: Alex Gaynor <[email protected]>
1 parent 138da90 commit d6951dc

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed
 

‎CHANGELOG.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
.. _v39-0-1:
5+
6+
39.0.1 - 2023-02-07
7+
~~~~~~~~~~~~~~~~~~~
8+
9+
* **SECURITY ISSUE** - Fixed a bug where ``Cipher.update_into`` accepted Python
10+
buffer protocol objects, but allowed immutable buffers. **CVE-2023-23931**
11+
* Updated Windows, macOS, and Linux wheels to be compiled with OpenSSL 3.0.8.
12+
413
.. _v39-0-0:
514

615
39.0.0 - 2023-01-01

‎src/cryptography/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"__copyright__",
1010
]
1111

12-
__version__ = "39.0.0"
12+
__version__ = "39.0.1"
1313

1414
__author__ = "The Python Cryptographic Authority and individual contributors"
1515
__copyright__ = "Copyright 2013-2022 {}".format(__author__)

‎src/cryptography/hazmat/backends/openssl/ciphers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def update_into(self, data: bytes, buf: bytes) -> int:
156156
data_processed = 0
157157
total_out = 0
158158
outlen = self._backend._ffi.new("int *")
159-
baseoutbuf = self._backend._ffi.from_buffer(buf)
159+
baseoutbuf = self._backend._ffi.from_buffer(buf, require_writable=True)
160160
baseinbuf = self._backend._ffi.from_buffer(data)
161161

162162
while data_processed != total_data_len:

‎tests/hazmat/primitives/test_ciphers.py

+8
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ def test_update_into_buffer_too_small(self, backend):
318318
with pytest.raises(ValueError):
319319
encryptor.update_into(b"testing", buf)
320320

321+
def test_update_into_immutable(self, backend):
322+
key = b"\x00" * 16
323+
c = ciphers.Cipher(AES(key), modes.ECB(), backend)
324+
encryptor = c.encryptor()
325+
buf = b"\x00" * 32
326+
with pytest.raises((TypeError, BufferError)):
327+
encryptor.update_into(b"testing", buf)
328+
321329
@pytest.mark.supported(
322330
only_if=lambda backend: backend.cipher_supported(
323331
AES(b"\x00" * 16), modes.GCM(b"\x00" * 12)

‎vectors/cryptography_vectors/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"__version__",
77
]
88

9-
__version__ = "39.0.0"
9+
__version__ = "39.0.1"

2 commit comments

Comments
 (2)

rmarviila commented on Aug 16, 2023

@rmarviila

This is the fixing related as: * Pyca Cryptography Vulnerable to Memory Corruption via 'update_into' Function *
Black Duck reference: BLACKDUCK - BDSA-2023-0242
Black Duck endpoint: https://blackduck.aa.com/api/vulnerabilities/BDSA-2023-0242/technical

rmarviila commented on Aug 16, 2023

@rmarviila

This is the fixing related as: * Pyca Cryptography Vulnerable to Memory Corruption via 'update_into' Function *
Black Duck reference: BLACKDUCK - BDSA-2023-0242
Black Duck endpoint: https://blackduck.aa.com/api/vulnerabilities/BDSA-2023-0242/technical

Please sign in to comment.