public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Lumir Balhar <lbalhar@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python3.6] f43: Security fixes for CVE-2026-12345, CVE-2026-19445, CVE-2026-19553
Date: Thu, 12 Nov 2026 11:49:01 GMT [thread overview]
Message-ID: <179448414184.1.8741422116582044203.rpms-python3.6-1cf98c9b9bae@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/python3.6
Branch : f43
Commit : 1cf98c9b9bae858026b45cca80ce885e3fddc92f
Author : Lumir Balhar <lbalhar@redhat.com>
Date : 2026-10-29T11:10:34+01:00
Stats : +857/-1 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/python3.6/c/1cf98c9b9bae858026b45cca80ce885e3fddc92f?branch=f43
Log:
Security fixes for CVE-2026-12345, CVE-2026-19445, CVE-2026-19553
Resolves: rhbz#2547342, rhbz#2545939, rhbz#2546325
---
diff --git a/00495-cve-2026-12345.patch b/00495-cve-2026-12345.patch
new file mode 100644
index 0000000..45a4f69
--- /dev/null
+++ b/00495-cve-2026-12345.patch
@@ -0,0 +1,433 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Stan Ulbrych <stan@python.org>
+Date: Tue, 29 Sep 2026 16:34:03 +0100
+Subject: 00495: gh-157579: Fix race condition in the cleanup of
+ `tempfile.TemporaryDirectory`
+
+Co-authored-by: Petr Viktorin <encukou@gmail.com>
+---
+ Doc/library/tempfile.rst | 9 +++
+ Lib/shutil.py | 30 ++++++----
+ Lib/tempfile.py | 120 ++++++++++++++++++++++++++++++++++----
+ Lib/test/test_shutil.py | 29 +++++++++
+ Lib/test/test_tempfile.py | 73 +++++++++++++++++++++++
+ 5 files changed, 241 insertions(+), 20 deletions(-)
+
+diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
+index 0d0da4d62e..ec1a8e4975 100644
+--- a/Doc/library/tempfile.rst
++++ b/Doc/library/tempfile.rst
+@@ -121,6 +121,15 @@ The module defines the following user-callable items:
+ The directory can be explicitly cleaned up by calling the
+ :func:`cleanup` method.
+
++ .. warning::
++
++ Cleanup is not robust against the tree being modified while it is removed.
++ Files outside of the tree may have their permissions and file flags reset.
++
++ On systems where :data:`shutil.rmtree.avoids_symlink_attacks` is
++ false, manipulating symbolic links during cleanup
++ may cause files outside of the tree to be removed.
++
+ .. versionadded:: 3.2
+
+
+diff --git a/Lib/shutil.py b/Lib/shutil.py
+index d687de1bbf..4a7731fc17 100644
+--- a/Lib/shutil.py
++++ b/Lib/shutil.py
+@@ -417,7 +417,8 @@ def _rmtree_safe_fd(topfd, path, onerror):
+ try:
+ dirfd = os.open(name, os.O_RDONLY, dir_fd=topfd)
+ except OSError:
+- onerror(os.open, fullname, sys.exc_info())
++ onerror(os.open, fullname, sys.exc_info(),
++ entry_name=name, dir_fd=topfd)
+ else:
+ try:
+ if os.path.samestat(orig_st, os.fstat(dirfd)):
+@@ -425,7 +426,8 @@ def _rmtree_safe_fd(topfd, path, onerror):
+ try:
+ os.rmdir(name, dir_fd=topfd)
+ except OSError:
+- onerror(os.rmdir, fullname, sys.exc_info())
++ onerror(os.rmdir, fullname, sys.exc_info(),
++ entry_name=name, dir_fd=topfd)
+ else:
+ try:
+ # This can only happen if someone replaces
+@@ -434,21 +436,24 @@ def _rmtree_safe_fd(topfd, path, onerror):
+ raise OSError("Cannot call rmtree on a symbolic "
+ "link")
+ except OSError:
+- onerror(os.path.islink, fullname, sys.exc_info())
++ onerror(os.path.islink, fullname, sys.exc_info(),
++ entry_name=name, dir_fd=topfd)
+ finally:
+ os.close(dirfd)
+ else:
+ try:
+ os.unlink(name, dir_fd=topfd)
+ except OSError:
+- onerror(os.unlink, fullname, sys.exc_info())
++ onerror(os.unlink, fullname, sys.exc_info(),
++ entry_name=name, dir_fd=topfd)
+
+ _use_fd_functions = ({os.open, os.stat, os.unlink, os.rmdir} <=
+ os.supports_dir_fd and
+ os.listdir in os.supports_fd and
+ os.stat in os.supports_follow_symlinks)
+
+-def rmtree(path, ignore_errors=False, onerror=None):
++def rmtree(path, ignore_errors=False, onerror=None, *, dir_fd=None,
++ _onexc_kwargs=False):
+ """Recursively delete a directory tree.
+
+ If ignore_errors is set, errors are ignored; otherwise, if onerror
+@@ -460,11 +465,16 @@ def rmtree(path, ignore_errors=False, onerror=None):
+
+ """
+ if ignore_errors:
+- def onerror(*args):
++ def onerror(*args, **kwargs):
+ pass
+ elif onerror is None:
+- def onerror(*args):
++ def onerror(*args, **kwargs):
+ raise
++ elif not _onexc_kwargs:
++ # Only the internal caller in tempfile asks for the extra arguments.
++ _onerror = onerror
++ def onerror(func, path, exc_info, **kwargs):
++ return _onerror(func, path, exc_info)
+ if _use_fd_functions:
+ # While the unsafe rmtree works fine on bytes, the fd based does not.
+ if isinstance(path, bytes):
+@@ -472,12 +482,12 @@ def rmtree(path, ignore_errors=False, onerror=None):
+ # Note: To guard against symlink races, we use the standard
+ # lstat()/open()/fstat() trick.
+ try:
+- orig_st = os.lstat(path)
++ orig_st = os.stat(path, dir_fd=dir_fd, follow_symlinks=False)
+ except Exception:
+ onerror(os.lstat, path, sys.exc_info())
+ return
+ try:
+- fd = os.open(path, os.O_RDONLY)
++ fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd)
+ except Exception:
+ onerror(os.lstat, path, sys.exc_info())
+ return
+@@ -485,7 +495,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
+ if os.path.samestat(orig_st, os.fstat(fd)):
+ _rmtree_safe_fd(fd, path, onerror)
+ try:
+- os.rmdir(path)
++ os.rmdir(path, dir_fd=dir_fd)
+ except OSError:
+ onerror(os.rmdir, path, sys.exc_info())
+ else:
+diff --git a/Lib/tempfile.py b/Lib/tempfile.py
+index 8e401f548a..4831207cc3 100644
+--- a/Lib/tempfile.py
++++ b/Lib/tempfile.py
+@@ -43,6 +43,7 @@ import os as _os
+ import shutil as _shutil
+ import errno as _errno
+ from random import Random as _Random
++from stat import S_ISLNK as _S_ISLNK
+ import weakref as _weakref
+
+ try:
+@@ -284,15 +285,69 @@ def _dont_follow_symlinks(func, path, *args):
+ func(path, *args)
+
+
+-def _resetperms(path):
++def _resetflags(path):
+ try:
+ chflags = _os.chflags
+ except AttributeError:
+ pass
+ else:
+ _dont_follow_symlinks(chflags, path, 0)
++
++def _resetperms(path):
++ _resetflags(path)
+ _dont_follow_symlinks(_os.chmod, path, 0o700)
+
++# True if TemporaryDirectory._rmtree() can work relative to open directories
++# instead of resolving paths again.
++_rmtree_use_dir_fd = (
++ {_os.chmod, _os.unlink, _os.stat} <= _os.supports_dir_fd
++ and _os.chmod in _os.supports_fd
++)
++
++def _resetperms_fd(dir_fd, path):
++ # Same as _resetperms(), but for the directory referred to by dir_fd.
++ if dir_fd is None:
++ _resetperms(path)
++ return
++ _resetflags(path)
++ _os.chmod(dir_fd, 0o700)
++
++try:
++ _nofollow_mode = _os.O_RDONLY | _os.O_NONBLOCK | _os.O_NOFOLLOW
++except AttributeError:
++ _nofollow_mode = None
++
++def _resetperms_at(name, dir_fd, path):
++ # Same as _resetperms(), but name is resolved relative to the directory
++ # file descriptor dir_fd. path is only used for os.chflags(), which
++ # doesn't support dir_fd or file descriptors.
++ if dir_fd is None:
++ _resetperms(path)
++ return
++ _resetflags(path)
++ if _os.chmod in _os.supports_follow_symlinks:
++ _os.chmod(name, 0o700, dir_fd=dir_fd, follow_symlinks=False)
++ else:
++ # dir_fd & follow_symlinks is not supported on this platform.
++ # Try chmod opening the file with O_NOFOLLOW.
++ if _nofollow_mode is not None:
++ try:
++ fd = _os.open(name, _nofollow_mode, dir_fd=dir_fd)
++ except OSError:
++ pass
++ else:
++ try:
++ _os.chmod(fd, 0o700)
++ finally:
++ _os.close(fd)
++ return
++ # If that did not work, we change by name, which is subject to a race
++ # condition.
++ stat = _os.lstat(name, dir_fd=dir_fd)
++ if not _S_ISLNK(stat.st_mode):
++ _os.chmod(name, 0o700, dir_fd=dir_fd)
++
++
+ # User visible interfaces.
+
+ def gettempprefix():
+@@ -812,27 +867,72 @@ class TemporaryDirectory(object):
+ warn_message="Implicitly cleaning up {!r}".format(self))
+
+ @classmethod
+- def _rmtree(cls, name):
+- def onerror(func, path, exc_info):
++ def _rmtree(cls, name, ignore_errors=False, repeated=False, dir_fd=None,
++ fullname=None):
++ if fullname is None:
++ fullname = name
++
++ def onerror(func, path, exc_info, entry_name=None, dir_fd=None):
+ if issubclass(exc_info[0], PermissionError):
++ if repeated and path == name:
++ if ignore_errors:
++ return
++ raise
++
++ # fullpath is path as seen from the working directory
++ fullpath = fullname + path[len(name):]
++ # base is path relative to dir_fd, the directory rmtree()
++ # reached it through, or the whole path when there is none
++ if dir_fd is None or not _rmtree_use_dir_fd:
++ base, dir_fd = path, None
++ elif entry_name is None:
++ base = path
++ else:
++ base = entry_name
++
+ try:
+ if path != name:
+- _resetperms(_os.path.dirname(path))
+- _resetperms(path)
++ # The parent directory of path is the one referred to
++ # by dir_fd.
++ _resetperms_fd(dir_fd, _os.path.dirname(fullpath))
++ _resetperms_at(base, dir_fd, fullpath)
+
+ try:
+- _os.unlink(path)
++ _os.unlink(base, dir_fd=dir_fd)
++ except IsADirectoryError:
++ cls._rmtree(base, ignore_errors=ignore_errors,
++ repeated=(path == name),
++ dir_fd=dir_fd, fullname=fullpath)
+ # PermissionError is raised on FreeBSD for directories
+- except (IsADirectoryError, PermissionError):
+- cls._rmtree(path)
++ except PermissionError:
++ # The PermissionError handler was originally added for
++ # FreeBSD in directories, but it seems that it is raised
++ # on Linux too.
++ # os.unlink() can also raise IsADirectoryError. It could
++ # raise NotADirectoryError and mask the PermissionError.
++ # So we must re-raise the current PermissionError if
++ # path is not a directory.
++ if not _os.path.isdir(fullpath):
++ if ignore_errors:
++ return
++ raise
++ cls._rmtree(base, ignore_errors=ignore_errors,
++ repeated=(path == name),
++ dir_fd=dir_fd, fullname=fullpath)
+ except FileNotFoundError:
+ pass
++ except OSError:
++ if ignore_errors:
++ return
++ raise
+ elif issubclass(exc_info[0], FileNotFoundError):
+ pass
+ else:
+- raise
++ if not ignore_errors:
++ raise
+
+- _shutil.rmtree(name, onerror=onerror)
++ _shutil.rmtree(name, onerror=onerror, dir_fd=dir_fd,
++ _onexc_kwargs=True)
+
+ @classmethod
+ def _cleanup(cls, name, warn_message):
+diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
+index 77101251ac..6a135c5364 100644
+--- a/Lib/test/test_shutil.py
++++ b/Lib/test/test_shutil.py
+@@ -255,6 +255,35 @@ class TestShutil(unittest.TestCase):
+ self.assertTrue(issubclass(exc[0], OSError))
+ self.errorState = 3
+
++ @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks,
++ 'requires the fd based implementation of rmtree()')
++ def test_onerror_kwargs(self):
++ os.mkdir(TESTFN)
++ self.addCleanup(shutil.rmtree, TESTFN)
++
++ child_dir_path = os.path.join(TESTFN, 'b')
++ child_file_path = os.path.join(child_dir_path, 'a')
++ os.mkdir(child_dir_path)
++ open(child_file_path, 'w').close()
++ old_child_dir_mode = os.stat(child_dir_path).st_mode
++ # Make unwritable.
++ new_mode = stat.S_IREAD|stat.S_IEXEC
++ os.chmod(child_dir_path, new_mode)
++
++ self.addCleanup(os.chmod, child_dir_path, old_child_dir_mode)
++
++ calls = []
++ def onerror(func, path, exc_info, entry_name=None, dir_fd=None):
++ calls.append((func, path, exc_info))
++ if func is os.unlink:
++ self.assertEqual(entry_name, os.path.basename(path))
++ self.assertTrue(os.path.samestat(
++ os.stat(path), os.stat(entry_name, dir_fd=dir_fd)))
++
++ shutil.rmtree(TESTFN, onerror=onerror, _onexc_kwargs=True)
++ self.assertIn((os.unlink, child_file_path),
++ [(func, path) for func, path, exc_info in calls])
++
+ def test_rmtree_does_not_choke_on_failing_lstat(self):
+ try:
+ orig_lstat = os.lstat
+diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
+index c5560e12e7..b7169661b5 100644
+--- a/Lib/test/test_tempfile.py
++++ b/Lib/test/test_tempfile.py
+@@ -8,6 +8,7 @@ import sys
+ import re
+ import warnings
+ import contextlib
++import shutil
+ import weakref
+ from unittest import mock
+
+@@ -1458,6 +1459,50 @@ class TestTemporaryDirectory(BaseTestCase):
+ new_flags = os.stat(dir1).st_flags
+ self.assertEqual(new_flags, old_flags)
+
++ @support.skip_unless_symlink
++ @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks,
++ 'requires the fd based implementation of rmtree()')
++ def test_cleanup_with_symlink_race(self):
++ # cleanup() should not operate on files outside of the temporary
++ # directory when a directory is replaced with a symlink while it
++ # recovers from a PermissionError (CVE-2026-12345).
++ with self.do_create(recurse=0) as target:
++ target_file = os.path.join(target, 'file1')
++ open(target_file, 'wb').close()
++ target_mode = os.stat(target_file).st_mode
++
++ d1 = self.do_create(recurse=0)
++ dir1 = os.path.join(d1.name, 'dir1')
++ os.mkdir(dir1)
++ open(os.path.join(dir1, 'file1'), 'wb').close()
++ # Removing contents of dir1 fails with a PermissionError, and
++ # dir1 is replaced with a symlink to target at the very moment
++ # cleanup() starts to recover from that error.
++ os.chmod(dir1, 0o500)
++ unlink = os.unlink
++ def hook(path, *, dir_fd=None):
++ try:
++ return unlink(path, dir_fd=dir_fd)
++ except PermissionError:
++ if not os.path.islink(dir1):
++ os.chmod(dir1, 0o700)
++ os.rename(dir1, dir1 + '_moved')
++ os.symlink(target, dir1)
++ raise
++ try:
++ with mock.patch('os.unlink', hook):
++ with contextlib.suppress(OSError):
++ d1.cleanup()
++ finally:
++ if os.path.islink(dir1):
++ os.unlink(dir1)
++ os.rename(dir1 + '_moved', dir1)
++ os.chmod(dir1, 0o700)
++ d1.cleanup()
++
++ self.assertTrue(os.path.exists(target_file))
++ self.assertEqual(os.stat(target_file).st_mode, target_mode)
++
+ @support.cpython_only
+ def test_del_on_collection(self):
+ # A TemporaryDirectory is deleted when garbage collected
+@@ -1570,6 +1615,34 @@ class TestTemporaryDirectory(BaseTestCase):
+ d.cleanup()
+ self.assertFalse(os.path.exists(d.name))
+
++ def test_parent_mode_preserved(self):
++ # Test that cleanup does not touch the parent directory,
++ # even if that prevents removal.
++ for mode in range(8):
++ mode <<= 6
++ with self.subTest(mode=format(mode, '03o')):
++ outer = self.do_create()
++ with outer:
++ d = self.do_create(dir=outer.name, dirs=2, files=2,
++ recurse=2)
++ with d:
++ os.chmod(outer.name, mode)
++ orig_mode = os.stat(outer.name).st_mode
++ try:
++ d.cleanup()
++ except PermissionError:
++ pass
++ self.assertEqual(os.stat(outer.name).st_mode, orig_mode)
++ outer.cleanup()
++ self.assertFalse(os.path.exists(outer.name))
++
++ @unittest.skipIf(sys.platform == 'win32', 'dirfd not used on Windows')
++ def test_cleanup_safe(self):
++ """Verify that cleanup uses the safer code path"""
++ # This is a regression test. Feel free to add exceptions for new
++ # platforms, but don't forget to update the docs.
++ self.assertTrue(tempfile._rmtree_use_dir_fd)
++
+ def check_flags(self, flags):
+ # skip the test if these flags are not supported (ex: FreeBSD 13)
+ filename = support.TESTFN
diff --git a/00496-cve-2026-19445.patch b/00496-cve-2026-19445.patch
new file mode 100644
index 0000000..788939a
--- /dev/null
+++ b/00496-cve-2026-19445.patch
@@ -0,0 +1,211 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Seth Michael Larson <seth@python.org>
+Date: Wed, 30 Sep 2026 09:35:21 -0500
+Subject: 00496: gh-156293: Use-after-free for server-side SSLContext with
+ sni_callback
+
+Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
+---
+ Doc/library/ssl.rst | 11 +++++++
+ Lib/test/test_ssl.py | 78 ++++++++++++++++++++++++++++++++++++++++++++
+ Modules/_ssl.c | 25 +++++++++++---
+ 3 files changed, 109 insertions(+), 5 deletions(-)
+
+diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
+index a534811f93..cb1deaceaa 100644
+--- a/Doc/library/ssl.rst
++++ b/Doc/library/ssl.rst
+@@ -1568,6 +1568,12 @@ to speed up repeated connections from the same clients.
+ :class:`SSLContext` representing a certificate chain that matches the server
+ name.
+
++ If the callback assigns a new context to :attr:`SSLSocket.context`, any
++ further ClientHello message on the same connection (for example after a
++ TLS 1.3 HelloRetryRequest) is dispatched to the new context's
++ *sni_callback*, if it has one; the original callback is not called again
++ for that connection.
++
+ Due to the early negotiation phase of the TLS connection, only limited
+ methods and attributes are usable like
+ :meth:`SSLSocket.selected_alpn_protocol` and :attr:`SSLSocket.context`.
+@@ -1595,6 +1601,11 @@ to speed up repeated connections from the same clients.
+
+ .. versionadded:: 3.4
+
++ .. versionchanged:: next
++ After the callback assigns a new :attr:`SSLSocket.context`, later
++ ClientHello messages on the connection are dispatched to the new
++ context's *sni_callback*.
++
+ .. method:: SSLContext.load_dh_params(dhfile)
+
+ Load the key generation parameters for Diffie-Hellman (DH) key exchange.
+diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
+index 58af775710..f62ab71560 100644
+--- a/Lib/test/test_ssl.py
++++ b/Lib/test/test_ssl.py
+@@ -1562,6 +1562,84 @@ class MemoryBIOTests(unittest.TestCase):
+ self.assertRaises(TypeError, bio.write, True)
+ self.assertRaises(TypeError, bio.write, 1)
+
++ def test_sni_callback_context_released_and_callback_raises(self):
++ # Variant of the test below without a HelloRetryRequest: the callback
++ # switches the connection to another context, drops the last
++ # references to the context that carries it, and raises. The C
++ # callback must not touch that context after the Python callback
++ # returned.
++ client_ctx, server_ctx, hostname = testing_context()
++ leaf_ctx = server_ctx
++
++ def sni_cb(sslobj, server_name, ctx):
++ sslobj.context = leaf_ctx
++ del ctx
++ raise LookupError("no certificate for " + repr(server_name))
++
++ def make_server():
++ dispatch_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
++ dispatch_ctx.load_cert_chain(SIGNED_CERTFILE)
++ dispatch_ctx.set_servername_callback(sni_cb)
++ s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ server = dispatch_ctx.wrap_bio(s_in, s_out, server_side=True)
++ return server, s_in, s_out
++
++ server, s_in, s_out = make_server()
++ c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname)
++ with self.assertRaises(ssl.SSLWantReadError):
++ client.do_handshake()
++ s_in.write(c_out.read())
++ with self.assertRaises(ssl.SSLError):
++ server.do_handshake()
++ self.assertIs(server.context, leaf_ctx)
++
++ def test_sni_callback_context_released_before_second_client_hello(self):
++ # The SSLContext carrying sni_callback may be released by the
++ # application once the callback has switched the connection over to
++ # another context. If the server then sends a HelloRetryRequest, the
++ # second ClientHello makes OpenSSL consult the original SSL_CTX's
++ # servername callback again; that must not use the deallocated
++ # SSLContext object.
++ client_ctx, leaf_ctx, hostname = testing_context()
++ calls = []
++
++ def make_server():
++ dispatch_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
++ dispatch_ctx.load_cert_chain(SIGNED_CERTFILE)
++ # Force a HelloRetryRequest: the client offers an X25519 key
++ # share first, the server only accepts P-384.
++ dispatch_ctx.set_ecdh_curve("secp384r1")
++ def sni_cb(sslobj, server_name, ctx):
++ calls.append(server_name)
++ sslobj.context = leaf_ctx
++ dispatch_ctx.set_servername_callback(sni_cb)
++ s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ server = dispatch_ctx.wrap_bio(s_in, s_out, server_side=True)
++ return server, s_in, s_out, weakref.ref(dispatch_ctx)
++
++ # After this only the C-level SSL object references dispatch_ctx.
++ server, s_in, s_out, dispatch_ref = make_server()
++ c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname)
++ for _ in range(10):
++ for obj, out, peer_in in ((client, c_out, s_in),
++ (server, s_out, c_in)):
++ try:
++ obj.do_handshake()
++ except ssl.SSLWantReadError:
++ pass
++ if out.pending:
++ peer_in.write(out.read())
++ client.do_handshake()
++ server.do_handshake()
++ support.gc_collect()
++ self.assertIsNone(dispatch_ref())
++ self.assertGreaterEqual(len(calls), 1)
++ self.assertEqual(calls[0], hostname)
++ self.assertIs(server.context, leaf_ctx)
++ self.assertIsNotNone(client.cipher())
++
+
+ @unittest.skipUnless(_have_threads, "Needs threading module")
+ class SimpleBackgroundTests(unittest.TestCase):
+diff --git a/Modules/_ssl.c b/Modules/_ssl.c
+index d31e1960ec..c29072d96a 100644
+--- a/Modules/_ssl.c
++++ b/Modules/_ssl.c
+@@ -3049,6 +3049,9 @@ context_dealloc(PySSLContext *self)
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(self);
+ context_clear(self);
++ /* The SSL_CTX may outlive this object as the session_ctx of sockets that
++ were switched to another context; leave no Python callback behind. */
++ SSL_CTX_set_tlsext_servername_callback(self->ctx, NULL);
+ SSL_CTX_free(self->ctx);
+ #if HAVE_NPN
+ PyMem_FREE(self->npn_protocols);
+@@ -4066,7 +4069,7 @@ static int
+ _servername_callback(SSL *s, int *al, void *args)
+ {
+ int ret;
+- PySSLContext *ssl_ctx = (PySSLContext *) args;
++ PySSLContext *ssl_ctx;
+ PySSLSocket *ssl;
+ PyObject *servername_o;
+ PyObject *servername_idna;
+@@ -4078,18 +4081,29 @@ _servername_callback(SSL *s, int *al, void *args)
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ #endif
+
++ /* Do not use the SSL_CTX's servername arg to find the context: it is a
++ borrowed pointer to whichever _SSLContext installed the callback, and
++ that object may already be gone while OpenSSL still reaches this
++ callback through the connection's session_ctx (e.g. on the second
++ ClientHello after a HelloRetryRequest, once sni_callback has switched
++ the socket to another context). The socket's current context is
++ always alive. */
++ ssl = SSL_get_app_data(s);
++ assert(ssl != NULL);
++ ssl_ctx = ssl->ctx;
++ Py_INCREF(ssl_ctx);
++ assert(PySSLSocket_Check(ssl));
++
+ if (ssl_ctx->set_hostname == NULL) {
+ /* remove race condition in this the call back while if removing the
+ * callback is in progress */
++ Py_DECREF(ssl_ctx);
+ #ifdef WITH_THREAD
+ PyGILState_Release(gstate);
+ #endif
+ return SSL_TLSEXT_ERR_OK;
+ }
+
+- ssl = SSL_get_app_data(s);
+- assert(PySSLSocket_Check(ssl));
+-
+ /* The servername callback expects an argument that represents the current
+ * SSL connection and that has a .context attribute that can be changed to
+ * identify the requested hostname. Since the official API is the Python
+@@ -4152,6 +4166,7 @@ _servername_callback(SSL *s, int *al, void *args)
+ Py_DECREF(result);
+ }
+
++ Py_DECREF(ssl_ctx);
+ #ifdef WITH_THREAD
+ PyGILState_Release(gstate);
+ #endif
+@@ -4159,6 +4174,7 @@ _servername_callback(SSL *s, int *al, void *args)
+
+ error:
+ Py_DECREF(ssl_socket);
++ Py_DECREF(ssl_ctx);
+ *al = SSL_AD_INTERNAL_ERROR;
+ ret = SSL_TLSEXT_ERR_ALERT_FATAL;
+ #ifdef WITH_THREAD
+@@ -4199,7 +4215,6 @@ _ssl__SSLContext_set_servername_callback(PySSLContext *self, PyObject *cb)
+ Py_INCREF(cb);
+ self->set_hostname = cb;
+ SSL_CTX_set_tlsext_servername_callback(self->ctx, _servername_callback);
+- SSL_CTX_set_tlsext_servername_arg(self->ctx, self);
+ }
+ Py_RETURN_NONE;
+ #else
diff --git a/00497-cve-2026-19553.patch b/00497-cve-2026-19553.patch
new file mode 100644
index 0000000..4e30066
--- /dev/null
+++ b/00497-cve-2026-19553.patch
@@ -0,0 +1,194 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "T. Wouters" <thomas@python.org>
+Date: Thu, 1 Oct 2026 02:37:59 +0200
+Subject: 00497: gh-156793: Validate SSLContext.wrap_bio() parameters like
+ wrap_socket()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* gh-156793: Start the SSL handshake in the 3.10 hostname validation tests
+
+(cherry picked from commit 1697ea386c707142555d98a1263176bbbc014a96)
+(cherry picked from commit 869069d52ce0efab2f8c38197e92cdaaa312f1ed)
+
+Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
+Co-authored-by: Seth Larson <seth@python.org>
+Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
+Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
+Co-authored-by: T. Wouters <thomas@python.org>
+Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
+---
+ Doc/library/ssl.rst | 7 +++-
+ Lib/ssl.py | 9 +++++
+ Lib/test/test_ssl.py | 94 ++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 109 insertions(+), 1 deletion(-)
+
+diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
+index cb1deaceaa..45fd2223f1 100644
+--- a/Doc/library/ssl.rst
++++ b/Doc/library/ssl.rst
+@@ -1674,11 +1674,16 @@ to speed up repeated connections from the same clients.
+ incoming BIO and write data to the outgoing BIO.
+
+ The *server_side*, *server_hostname* and *session* parameters have the
+- same meaning as in :meth:`SSLContext.wrap_socket`.
++ same meaning as in :meth:`SSLContext.wrap_socket`, and are validated in
++ the same way: in particular a :exc:`ValueError` is raised when
++ :attr:`~SSLContext.check_hostname` is enabled but no *server_hostname* is
++ given, since there would be no name to match the peer's certificate
++ against.
+
+ .. versionchanged:: 3.6
+ *session* argument was added.
+
++
+ .. method:: SSLContext.session_stats()
+
+ Get statistics about the SSL sessions created or managed by this context.
+diff --git a/Lib/ssl.py b/Lib/ssl.py
+index 0114387c57..0c94c7e069 100644
+--- a/Lib/ssl.py
++++ b/Lib/ssl.py
+@@ -366,6 +366,15 @@ class SSLContext(_SSLContext):
+
+ def wrap_bio(self, incoming, outgoing, server_side=False,
+ server_hostname=None, session=None):
++ if server_side:
++ if server_hostname:
++ raise ValueError("server_hostname can only be specified "
++ "in client mode")
++ if session is not None:
++ raise ValueError("session can only be specified in "
++ "client mode")
++ if self.check_hostname and not server_hostname:
++ raise ValueError("check_hostname requires server_hostname")
+ sslobj = self._wrap_bio(incoming, outgoing, server_side=server_side,
+ server_hostname=server_hostname)
+ return SSLObject(sslobj, session=session)
+diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
+index f62ab71560..8c3316680c 100644
+--- a/Lib/test/test_ssl.py
++++ b/Lib/test/test_ssl.py
+@@ -3,6 +3,7 @@
+ import sys
+ import unittest
+ from test import support
++import contextlib
+ import socket
+ import select
+ import time
+@@ -201,6 +202,36 @@ def test_wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLS, *,
+ context.set_ciphers(ciphers)
+ return context.wrap_socket(sock, **kwargs)
+
++
++
++def connected_bio_pair(client_context, server_context, hostname, max_retry=5):
++ """Handshake a client and a server SSLObject against each other.
++
++ Everything happens in memory, so this needs no socket and no thread.
++ Returns the two objects followed by their four BIOs, in the order
++ client, server, c_in, c_out, s_in, s_out.
++ """
++ c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO()
++ client = client_context.wrap_bio(c_in, c_out, server_hostname=hostname)
++ server = server_context.wrap_bio(s_in, s_out, server_side=True)
++
++ # Loop on the handshake for a bit to get it settled
++ for _ in range(max_retry):
++ with contextlib.suppress(ssl.SSLWantReadError):
++ client.do_handshake()
++ if c_out.pending:
++ s_in.write(c_out.read())
++ with contextlib.suppress(ssl.SSLWantReadError):
++ server.do_handshake()
++ if s_out.pending:
++ c_in.write(s_out.read())
++ # Now the handshakes should be complete (don't raise WantReadError)
++ client.do_handshake()
++ server.do_handshake()
++ return client, server, c_in, c_out, s_in, s_out
++
++
+ class BasicSocketTests(unittest.TestCase):
+
+ def test_constants(self):
+@@ -1500,6 +1531,7 @@ class SSLErrorTests(unittest.TestCase):
+ self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ)
+
+
++
+ class MemoryBIOTests(unittest.TestCase):
+
+ def test_read_write(self):
+@@ -3863,6 +3895,68 @@ def testing_context():
+ return client_context, server_context, 'localhost'
+
+
++class TestWrapBioValidation(unittest.TestCase):
++ """Ensure wrap_bio() validates parameters the same way wrap_socket() does."""
++
++ def test_check_hostname_requires_server_hostname(self):
++ # wrap_bio() used to accept a context asking for hostname checking
++ # without a name to check against, and then verify the certificate
++ # chain but never the peer's identity, with check_hostname still
++ # reporting True and nothing reporting the check had been skipped.
++ # It must refuse that call, as wrap_socket() already did.
++ client_context, _, hostname = testing_context()
++ self.assertTrue(client_context.check_hostname)
++
++ for server_hostname in (None, ""):
++ with self.subTest(server_hostname=server_hostname):
++ with self.assertRaisesRegex(
++ ValueError,
++ "check_hostname requires server_hostname"):
++ client_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
++ server_hostname=server_hostname)
++ # The sibling constructor refuses the very same call.
++ with socket.socket() as sock:
++ with self.assertRaisesRegex(
++ ValueError,
++ "check_hostname requires server_hostname"):
++ client_context.wrap_socket(
++ sock, server_hostname=server_hostname)
++
++ # A name was all that was missing.
++ client_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
++ server_hostname=hostname)
++
++ # Asking for no hostname check remains a way to say so explicitly.
++ context = ssl.SSLContext(ssl.PROTOCOL_TLS)
++ self.assertFalse(context.check_hostname)
++ context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO())
++
++ def test_server_side_bad_params(self):
++ # A server neither sends a hostname nor resumes a client's session,
++ # so wrap_bio() rejects both in server mode like wrap_socket()
++ client_context, server_context, hostname = testing_context()
++
++ with self.assertRaisesRegex(
++ ValueError,
++ "server_hostname can only be specified in client mode"):
++ server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
++ server_side=True,
++ server_hostname=hostname)
++
++ client, server, *_ = connected_bio_pair(
++ client_context, server_context, hostname)
++ session = client.session
++ self.assertIsNotNone(session)
++ with self.assertRaisesRegex(
++ ValueError, "session can only be specified in client mode"):
++ server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
++ server_side=True, session=session)
++
++ # Neither argument is what a server passes, so this still works.
++ server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
++ server_side=True)
++
++
+ @unittest.skipUnless(ssl.HAS_TLSv1_3, "Test needs TLS 1.3")
+ class TestPostHandshakeAuth(unittest.TestCase):
+ def test_pha_setter(self):
diff --git a/python3.6.spec b/python3.6.spec
index 37e9316..22d8ab6 100644
--- a/python3.6.spec
+++ b/python3.6.spec
@@ -17,7 +17,7 @@ URL: https://www.python.org/
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
-Release: 59%{?dist}
+Release: 60%{?dist}
# Python is Python
# pip MIT is and bundles:
# appdirs: MIT
@@ -963,6 +963,20 @@ Patch489: 00489-openssl-3.5.7.patch
# - gh-115627: Fix ssl test_pha_required_nocert() (GH-117821)
Patch493: 00493-fix-test_pha_required_nocert-race-condition.patch
+# 00495 # 252a03b2e5c6e8712c4ee13c75bc0f272f7e2039
+# gh-157579: Fix race condition in the cleanup of `tempfile.TemporaryDirectory`
+Patch495: 00495-cve-2026-12345.patch
+
+# 00496 # 456e16823a862c89758897a83293e133ab66dbfe
+# gh-156293: Use-after-free for server-side SSLContext with sni_callback
+Patch496: 00496-cve-2026-19445.patch
+
+# 00497 # e38c660251dbb1088e56876a0d3b2b6b66e4fe89
+# gh-156793: Validate SSLContext.wrap_bio() parameters like wrap_socket()
+#
+# * gh-156793: Start the SSL handshake in the 3.10 hostname validation tests
+Patch497: 00497-cve-2026-19553.patch
+
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@@ -2264,6 +2278,10 @@ CheckPython optimized
# ======================================================
%changelog
+* Tue Oct 27 2026 Lumír Balhar <lbalhar@redhat.com> - 3.6.15-60
+- Security fixes for CVE-2026-12345, CVE-2026-19445, CVE-2026-19553
+Resolves: rhbz#2547342, rhbz#2545939, rhbz#2546325
+
* Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 3.6.15-59
- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
reply other threads:[~2026-11-12 11:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179448414184.1.8741422116582044203.rpms-python3.6-1cf98c9b9bae@fedoraproject.org \
--to=lbalhar@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox