Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python310 for openSUSE:Factory checked in at 2026-11-28 23:24:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python310 (Old) and /work/SRC/openSUSE:Factory/.python310.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python310" Sat Nov 28 23:24:39 2026 rev:88 rq:1401212 version:3.10.22 Changes: -------- --- /work/SRC/openSUSE:Factory/python310/python310.changes 2026-11-25 16:14:07.548374534 +0100 +++ /work/SRC/openSUSE:Factory/.python310.new.1340718/python310.changes 2026-11-28 23:25:37.063476015 +0100 @@ -1,0 +2,28 @@ +Wed Nov 25 20:59:56 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-115791: Prevent shadowing stdlib in + gzip/tarfile/zipfile CLI (bsc#1290431) + CVE-2026-115791-prevent-shadowing-stdlib-cli.patch + +------------------------------------------------------------------- +Wed Nov 25 20:49:16 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-19552: Check hostname in ssl.get_server_certificate + with custom ca_certs (bsc#1290435) + CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch + +------------------------------------------------------------------- +Wed Nov 25 20:46:02 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-16052: Refuse ; in all cookie attributes except + Comment (bsc#1290439) + CVE-2026-16052-cookie-refuse-semicolon.patch + +------------------------------------------------------------------- +Wed Nov 25 20:43:07 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-124249: Check cookie policy before deleting expired + cookies in http.cookiejar (bsc#1290433) + CVE-2026-124249-cookiejar-expired-cookie-policy.patch + +------------------------------------------------------------------- New: ---- CVE-2026-115791-prevent-shadowing-stdlib-cli.patch CVE-2026-124249-cookiejar-expired-cookie-policy.patch CVE-2026-16052-cookie-refuse-semicolon.patch CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch ----------(New B)---------- New: gzip/tarfile/zipfile CLI (bsc#1290431) CVE-2026-115791-prevent-shadowing-stdlib-cli.patch New: cookies in http.cookiejar (bsc#1290433) CVE-2026-124249-cookiejar-expired-cookie-policy.patch New: Comment (bsc#1290439) CVE-2026-16052-cookie-refuse-semicolon.patch New: with custom ca_certs (bsc#1290435) CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python310.spec ++++++ --- /var/tmp/diff_new_pack.D08nW3/_old 2026-11-28 23:25:38.599540173 +0100 +++ /var/tmp/diff_new_pack.D08nW3/_new 2026-11-28 23:25:38.602540298 +0100 @@ -245,6 +245,18 @@ # PATCH-FIX-UPSTREAM CVE-2026-114583-tarfile-reject-link-at-destination.patch bsc#1288258 [email protected] # Reject links replacing the destination in tarfile.tar_filter Patch68: CVE-2026-114583-tarfile-reject-link-at-destination.patch +# PATCH-FIX-UPSTREAM CVE-2026-124249-cookiejar-expired-cookie-policy.patch bsc#1290433 [email protected] +# Check cookie policy before deleting expired cookies in http.cookiejar +Patch69: CVE-2026-124249-cookiejar-expired-cookie-policy.patch +# PATCH-FIX-UPSTREAM CVE-2026-16052-cookie-refuse-semicolon.patch bsc#1290439 [email protected] +# Refuse ; in all cookie attributes except Comment +Patch70: CVE-2026-16052-cookie-refuse-semicolon.patch +# PATCH-FIX-UPSTREAM CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch bsc#1290435 [email protected] +# Check hostname in ssl.get_server_certificate with custom ca_certs +Patch71: CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch +# PATCH-FIX-UPSTREAM CVE-2026-115791-prevent-shadowing-stdlib-cli.patch bsc#1290431 [email protected] +# Prevent shadowing stdlib in gzip/tarfile/zipfile CLI +Patch72: CVE-2026-115791-prevent-shadowing-stdlib-cli.patch ### END OF PATCHES BuildRequires: autoconf-archive BuildRequires: automake ++++++ CVE-2026-115791-prevent-shadowing-stdlib-cli.patch ++++++ >From dad645daa2de1d1ccb1a905627ab0bf56dd23b8f Mon Sep 17 00:00:00 2001 From: Victor Stinner <[email protected]> Date: Tue, 10 Nov 2026 01:35:37 +0100 Subject: [PATCH] [3.14] gh-161705: Prevent shadowing stdlib in gzip/tarfile/zipfile CLI (#161706) (#161719) gh-161705: Prevent shadowing stdlib in gzip/tarfile/zipfile CLI (#161706) Remove sys.path[0] in gzip, tarfile and zipfile command line interface to prevent shadowing standard library modules from extracted files. * Add sys._path0 variable. * pymain_sys_path_add_path0() sets sys._path0. * Add runpy._remove_sys_path0(). * gzip, tarfile and zipfile main functions now call _remove_sys_path0() to prevent shadowing stdlib modules from extracted files. Backport to 3.11: add test.support.make_clean_env() function and add Py_NewRef(Py_None) in sysmodule.c. (cherry picked from commit e891a9117985888df3e5d48145cf07ddda098335) Co-authored-by: Gregory P. Smith <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> (cherry picked from commit 8aa5d657e4d3f1a4cca5ff6c976e2e868e0a9056) Backport to 3.10: no sys._stdlib_dir (fall back to the directory of os.__file__), no sys.flags.safe_path (use sys.flags.isolated), drop zipfile metadata_encoding test changes (3.10 CLI tests use subprocesses only), drop init_config.rst/cmdline.rst doc changes. --- Doc/library/sys.rst | 17 + Lib/gzip.py | 5 Lib/runpy.py | 22 ++ Lib/tarfile.py | 4 Lib/test/support/__init__.py | 10 + Lib/test/test_runpy.py | 90 ++++++++++ Lib/test/test_sys.py | 9 + Lib/zipfile.py | 4 Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst | 6 Modules/main.c | 4 Python/pathconfig.c | 2 Python/sysmodule.c | 2 12 files changed, 174 insertions(+), 1 deletion(-) --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1156,6 +1156,23 @@ :data:`sys.path`. +.. data:: _path0 + + Path prepended to :data:`sys.path` at Python startup: + + * Current directory if running a module + with ``python -m module`` command line. + * Script's directory if running a script + with ``python script.py``. + * Otherwise an empty string, which means the current working directory, + for ``python -c code`` or ``python`` (REPL) command line. + + If :option:`-I` command line option is used, :data:`sys._path0` is + ``None`` and :data:`sys.path` is left unchanged. + + .. versionadded:: next + + .. data:: path_hooks A list of callables that take a path argument to try to create a --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -559,6 +559,11 @@ def main(): from argparse import ArgumentParser + import runpy + + # Prevent shadowing a stdlib module from the extracted file + runpy._remove_sys_path0() + parser = ArgumentParser(description= "A simple command line interface for the gzip module: act like gzip, " "but do not delete the input file.") --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -312,6 +312,28 @@ pass +def _remove_sys_path0(): + """ + Remove sys._path0 from sys.path. Do nothing if sys._path0 is + the standard library directory or if it has already been removed. + """ + path0 = sys._path0 + if path0 is None: + return + + stdlib_dir = getattr(sys, '_stdlib_dir', None) + if stdlib_dir is None: + stdlib_dir = os.path.dirname(os.__file__) + if path0 == stdlib_dir: + return + + # Remove all path0 copies, not only the first one. + # We are intentionally not trying to normalize & match alternate + # representations of path0, this is only intended to remove copies + # of the exact value the runtime itself may have added. + sys.path[:] = [path for path in sys.path if path != path0] + + if __name__ == "__main__": # Run the module specified as the next command line argument if len(sys.argv) < 2: --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2968,6 +2968,10 @@ def main(): import argparse + import runpy + + # Prevent shadowing stdlib modules from extracted files + runpy._remove_sys_path0() description = 'A simple command-line interface for tarfile module.' parser = argparse.ArgumentParser(description=description) --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2164,3 +2164,13 @@ C0 control characters defined as the byte range 0x00-0x1F, and 0x7F. """ return [chr(c) for c in range(0x00, 0x20)] + ["\x7F"] + + +def make_clean_env() -> dict[str, str]: + clean_env = os.environ.copy() + for k in clean_env.copy(): + if k.startswith("PYTHON"): + clean_env.pop(k) + clean_env.pop("FORCE_COLOR", None) + clean_env.pop("NO_COLOR", None) + return clean_env --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -12,8 +12,10 @@ import textwrap import unittest import warnings +from test import support from test.support import no_tracing, verbose from test.support.import_helper import forget, make_legacy_pyc, unload +from test.support import os_helper from test.support.os_helper import create_empty_file, temp_dir from test.support.script_helper import make_script, make_zip_script @@ -831,5 +833,93 @@ self.assertSigInt([sys.executable, "-m", ham.stem], cwd=ham.parent) +class MiscTests(unittest.TestCase): + def test_remove_sys_path0(self): + # Check that all path0 copies are removed + PATH0 = '/path/zero' + STDLIB_PATH = os.path.dirname(os.__file__) + OTHER_PATH = '/other/path' + sys_path = [PATH0, STDLIB_PATH, PATH0, '', OTHER_PATH, PATH0] + expected = [STDLIB_PATH, '', OTHER_PATH] + with (support.swap_attr(sys, '_path0', PATH0), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Calling it twice does nothing + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Do nothing if sys._path0 is stdlib_dir + sys_path = ['', STDLIB_PATH, OTHER_PATH] + expected = sys_path.copy() + with (support.swap_attr(sys, '_path0', STDLIB_PATH), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Do nothing if sys._path0 is None + sys_path = ['', STDLIB_PATH, OTHER_PATH] + expected = sys_path.copy() + with (support.swap_attr(sys, '_path0', None), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + def run_python(self, *args, PYTHONPATH=None): + cmd = [sys.executable, *args] + env = support.make_clean_env() + if PYTHONPATH: + env['PYTHONPATH'] = PYTHONPATH + import subprocess + proc = subprocess.run(cmd, text=True, stderr=subprocess.PIPE, env=env) + self.assertEqual(proc.returncode, 0, proc.stderr) + + def test_remove_sys_path0_run_python(self): + import textwrap + CODE = textwrap.dedent(""" + import runpy, sys + + # Remove sys.path[0] + orig_path = sys.path.copy() + path0 = sys._path0 + runpy._remove_sys_path0() + + if path0 is not None and path0 in sys.path: + raise Exception(f"path0 {path0!r} found in sys.path {sys.path!r}") + if not getattr(sys.flags, 'safe_path', sys.flags.isolated): + if sys.path == orig_path: + raise Exception("sys.path was not changed") + else: + if sys.path != orig_path: + raise Exception("sys.path was changed") + + # Calling it twice must do nothing + clean_path = sys.path.copy() + runpy._remove_sys_path0() + if sys.path != clean_path: + raise Exception("sys.path was changed") + """) + + # Test "python -c code" + self.run_python('-c', CODE) + self.run_python('-I', '-c', CODE) + + import tempfile + with tempfile.TemporaryDirectory() as tmpdir: + name = 'test_remove_sys_path0' + filename = os.path.join(tmpdir, f'{name}.py') + with open(filename, 'w') as fp: + fp.write(CODE) + + # Test "python script.py" + self.run_python(filename) + self.run_python('-I', filename) + + with os_helper.change_cwd(tmpdir): + # Test "python -m module" + self.run_python('-m', name) + + if __name__ == "__main__": unittest.main() --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1134,6 +1134,15 @@ self.assertIn('Traceback (most recent call last):\n', err) self.assertIn('Exception: hook_func failed\n', err) + def test_path(self): + self.assertIsInstance(sys.path, list) + for path in sys.path: + self.assertIsInstance(path, str) + + def test_path0(self): + self.assertTrue(sys._path0 is None or isinstance(sys._path0, str), + sys._path0) + @test.support.cpython_only class SizeofTest(unittest.TestCase): --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -2494,6 +2494,10 @@ def main(args=None): import argparse + import runpy + + # Prevent shadowing stdlib modules from extracted files + runpy._remove_sys_path0() description = 'A simple command-line interface for zipfile module.' parser = argparse.ArgumentParser(description=description) --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst @@ -0,0 +1,6 @@ +.. cve: CVE-2026-115791 + +Remove ``sys.path[0]`` in :mod:`gzip`, :mod:`tarfile` and :mod:`zipfile` +command line interface to prevent shadowing standard library modules from +extracted files. Issue reported by Jelle Zijlstra, patch by Gregory P. +Smith and Victor Stinner. --- a/Modules/main.c +++ b/Modules/main.c @@ -174,6 +174,10 @@ return -1; } + if (PyDict_SetItemString(sysdict, "_path0", path0) < 0) { + return -1; + } + if (PyList_Insert(sys_path, 0, path0)) { return -1; } --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -607,7 +607,7 @@ } /* Compute module search path from argv[0] or the current working - directory ("-m module" case) which will be prepended to sys.argv: + directory ("-m module" case) which will be prepended to sys.path: sys.path[0]. Return 1 if the path is correctly resolved and written into *path0_p. --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2911,6 +2911,8 @@ SET_SYS("path_importer_cache", PyDict_New()); SET_SYS("path_hooks", PyList_New(0)); + SET_SYS("_path0", Py_NewRef(Py_None)); + if (_PyErr_Occurred(tstate)) { goto err_occurred; } ++++++ CVE-2026-124249-cookiejar-expired-cookie-policy.patch ++++++ >From ee5deaa5a093df60aac87ef51ce3d4b8ee843441 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora <[email protected]> Date: Sat, 7 Nov 2026 21:53:13 +0200 Subject: [PATCH] gh-161569: Check cookie policy before deleting expired cookies in `http.cookiejar` (GH-161570) gh-161569: Check cookie policy before deleting expired cookies in http.cookiejar An expired Set-Cookie header was allowed to delete a stored cookie using the Domain and Path attributes taken verbatim from the header, before CookiePolicy.set_ok() was consulted. A response from one host could therefore delete cookies belonging to any other domain in a shared jar. The policy is now consulted before an expired cookie may delete an existing one, as required by RFC 6265 section 5.3. (cherry picked from commit 8eb3d2c1c41ca7ce628554413981c1eb763a1494) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Victor Stinner <[email protected]> --- Lib/http/cookiejar.py | 45 +++++++++-------- Lib/test/test_http_cookiejar.py | 49 +++++++++++++++++++ ...11-07-01-43-49.gh-issue-161569.cookiej.rst | 7 +++ 3 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2026-11-07-01-43-49.gh-issue-161569.cookiej.rst Index: Python-3.10.22/Lib/http/cookiejar.py =================================================================== --- Python-3.10.22.orig/Lib/http/cookiejar.py 2026-11-20 17:10:52.861534389 +0100 +++ Python-3.10.22/Lib/http/cookiejar.py 2026-11-25 21:42:14.488982862 +0100 @@ -1557,28 +1557,33 @@ if expires is Absent: expires = None discard = True - elif expires <= self._now: - # Expiry date in past is request to delete cookie. This can't be - # in DefaultCookiePolicy, because can't delete cookies there. - try: - self.clear(domain, path, name) - except KeyError: - pass - _debug("Expiring cookie, domain='%s', path='%s', name='%s'", - domain, path, name) + + cookie = Cookie(version, + name, value, + port, port_specified, + domain, domain_specified, domain_initial_dot, + path, path_specified, + secure, + expires, + discard, + comment, + comment_url, + rest) + + if expires is not None and expires <= self._now: + # RFC 6265 section 5.3 ignores the cookie entirely if its Domain + # attribute does not match the request host (step 6) before an + # existing cookie is removed (steps 11-12) + if self._policy.set_ok(cookie, request): + try: + self.clear(domain, path, name) + except KeyError: + pass + _debug("Expiring cookie, domain='%s', path='%s', name='%s'", + domain, path, name) return None - return Cookie(version, - name, value, - port, port_specified, - domain, domain_specified, domain_initial_dot, - path, path_specified, - secure, - expires, - discard, - comment, - comment_url, - rest) + return cookie def _cookies_from_attrs_set(self, attrs_set, request): cookie_tuples = self._normalized_cookie_tuples(attrs_set) Index: Python-3.10.22/Lib/test/test_http_cookiejar.py =================================================================== --- Python-3.10.22.orig/Lib/test/test_http_cookiejar.py 2026-11-20 17:10:55.055469318 +0100 +++ Python-3.10.22/Lib/test/test_http_cookiejar.py 2026-11-25 21:42:14.490222546 +0100 @@ -653,6 +653,55 @@ # XXX RFC 2965 expiry rules (some apply to V0 too) + def test_expired_cookie_from_other_domain_is_ignored(self): + c = CookieJar() + interact_netscape(c, "http://www.victim.test/", + 'session=secret; Domain=.victim.test; Path=/') + + for domain in ('.victim.test', 'victim.test'): + for expires in ( + 'Max-Age=0', + 'Expires=Thu, 01 Jan 1970 00:00:00 GMT', + ): + hdr = f'session=x; Domain={domain}; Path=/; {expires}' + with self.subTest(hdr=hdr): + interact_netscape(c, "http://www.attacker.test/", hdr) + self.assertEqual(len(c), 1) + self.assertIn( + 'session=secret', + interact_netscape(c, "http://www.victim.test/")) + + interact_netscape(c, "http://www.victim.test/", + 'session=x; Domain=.victim.test; Path=/; Max-Age=0') + self.assertEqual(len(c), 0) + + def test_expired_cookie_from_other_path_is_ignored(self): + pol = DefaultCookiePolicy(strict_ns_set_path=True) + c = CookieJar(pol) + interact_netscape(c, "http://www.acme.com/a/", + 'token=secret; Path=/a') + self.assertEqual(len(c), 1) + interact_netscape(c, "http://www.acme.com/b/", + 'token=x; Path=/a; Max-Age=0') + self.assertEqual(len(c), 1) + interact_netscape(c, "http://www.acme.com/a/", + 'token=x; Path=/a; Max-Age=0') + self.assertEqual(len(c), 0) + + def test_expired_cookie_for_blocked_domain_is_ignored(self): + c = CookieJar() + interact_netscape(c, "http://www.victim.test/", + 'session=secret; Domain=.victim.test; Path=/') + self.assertEqual(len(c), 1) + c.set_policy(DefaultCookiePolicy(blocked_domains=[".victim.test"])) + interact_netscape(c, "http://www.victim.test/", + 'session=x; Domain=.victim.test; Path=/; Max-Age=0') + self.assertEqual(len(c), 1) + c.set_policy(DefaultCookiePolicy()) + interact_netscape(c, "http://www.victim.test/", + 'session=x; Domain=.victim.test; Path=/; Max-Age=0') + self.assertEqual(len(c), 0) + def test_default_path(self): # RFC 2965 pol = DefaultCookiePolicy(rfc2965=True) Index: Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-07-01-43-49.gh-issue-161569.cookiej.rst =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-07-01-43-49.gh-issue-161569.cookiej.rst 2026-11-25 21:42:14.492247103 +0100 @@ -0,0 +1,7 @@ +.. cve: CVE-2026-124249 + +Fix :class:`http.cookiejar.CookieJar` deleting a stored cookie when a +response from an unrelated host sets an already expired cookie with a +``Domain`` or ``Path`` attribute pointing at that cookie. The cookie policy +is now consulted before an expired cookie is allowed to delete an existing +one. ++++++ CVE-2026-16052-cookie-refuse-semicolon.patch ++++++ >From e84bb3c643f0329eff783d5b4e5806993f802e09 Mon Sep 17 00:00:00 2001 From: Brett Smith <[email protected]> Date: Thu, 12 Nov 2026 10:50:42 -0500 Subject: [PATCH] [3.11] gh-161707: Refuse `;` in all cookie attributes except Comment (cherry picked from commit 27026842f6774c167295f4b59972589f12ec5987) Co-authored-by: Brett Smith <[email protected]> Co-authored-by: Victor Stinner <[email protected]> --- Doc/library/http.cookies.rst | 13 +++++++ Lib/http/cookies.py | 38 +++++++++++-------- Lib/test/test_http_cookies.py | 24 ++++++++++++ ...-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst | 5 +++ 4 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst Index: Python-3.10.22/Doc/library/http.cookies.rst =================================================================== --- Python-3.10.22.orig/Doc/library/http.cookies.rst 2026-10-01 02:48:01.000000000 +0200 +++ Python-3.10.22/Doc/library/http.cookies.rst 2026-11-25 21:44:57.137099269 +0100 @@ -163,6 +163,11 @@ .. versionchanged:: 3.8 Added support for the :attr:`samesite` attribute. + .. versionchanged:: next + :meth:`!__setitem__` and :meth:`!__ior__` now raise :exc:`CookieError` if + a value string for any attribute except :attr:`comment` contains the + reserved separator character ``;``. (If :attr:`comment` contains ``;`` + it will be escaped in the output.) .. attribute:: Morsel.value @@ -222,6 +227,10 @@ .. versionchanged:: 3.5 an error is raised for invalid keys. + .. versionchanged:: next + :exc:`CookieError` is now raised if a value string for any attribute + except :attr:`comment` contains the reserved separator character ``;``. + (If :attr:`comment` contains ``;`` it will be escaped in the output.) .. method:: Morsel.copy(value) @@ -236,6 +245,10 @@ Raise an error if key is not a valid :rfc:`2109` attribute, otherwise behave the same as :meth:`dict.setdefault`. + .. versionchanged:: next + :exc:`CookieError` is now raised if the value string for any attribute + except :attr:`comment` contains the reserved separator character ``;``. + (If :attr:`comment` contains ``;`` it will be escaped in the output.) .. _cookie-example: Index: Python-3.10.22/Lib/http/cookies.py =================================================================== --- Python-3.10.22.orig/Lib/http/cookies.py 2026-11-23 12:57:49.923367132 +0100 +++ Python-3.10.22/Lib/http/cookies.py 2026-11-25 21:44:57.138074807 +0100 @@ -297,20 +297,31 @@ def coded_value(self): return self._coded_value + def _check_attribute(self, key, val): + """Normalize and validate an attribute name and value + + Raise `CookieError` if the key is not a recognized attribute name or + value contains illegal characters. Otherwise return the canonicalized + key. + """ + key = key.lower() + val_str = str(val) + if key not in self._reserved: + raise CookieError(f"Invalid attribute {key!r}") + if _has_control_character(key, val_str): + raise CookieError(f"Control characters are not allowed in cookies {key!r} {val!r}") + # Comment is quoted like a cookie value so semicolons can be escaped. + # No other attribute expects `;` in the value, so refuse it. + if key != 'comment' and ';' in val_str: + raise CookieError(f"Reserved character ';' is not allowed in cookie attribute value {key!r} {val!r}") + return key + def __setitem__(self, K, V): - K = K.lower() - if not K in self._reserved: - raise CookieError("Invalid attribute %r" % (K,)) - if _has_control_character(K, V): - raise CookieError(f"Control characters are not allowed in cookies {K!r} {V!r}") + K = self._check_attribute(K, V) dict.__setitem__(self, K, V) def setdefault(self, key, val=None): - key = key.lower() - if key not in self._reserved: - raise CookieError("Invalid attribute %r" % (key,)) - if _has_control_character(key, val): - raise CookieError("Control characters are not allowed in cookies %r %r" % (key, val,)) + key = self._check_attribute(key, val) return dict.setdefault(self, key, val) def __eq__(self, morsel): @@ -332,12 +343,7 @@ def update(self, values): data = {} for key, val in dict(values).items(): - key = key.lower() - if key not in self._reserved: - raise CookieError("Invalid attribute %r" % (key,)) - if _has_control_character(key, val): - raise CookieError("Control characters are not allowed in " - f"cookies {key!r} {val!r}") + key = self._check_attribute(key, val) data[key] = val dict.update(self, data) Index: Python-3.10.22/Lib/test/test_http_cookies.py =================================================================== --- Python-3.10.22.orig/Lib/test/test_http_cookies.py 2026-11-23 12:57:49.923838842 +0100 +++ Python-3.10.22/Lib/test/test_http_cookies.py 2026-11-25 21:44:57.138671702 +0100 @@ -569,6 +569,30 @@ with self.assertRaises(cookies.CookieError): morsel |= {c0: "val"} + def test_no_semicolons_in_attribute_values(self): + for attrkey, attrname in cookies.Morsel._reserved.items(): + if attrname == "Comment": + continue + with self.subTest(attrkey=attrkey, attrname=attrname): + morsel = cookies.Morsel() + with self.assertRaises(cookies.CookieError): + morsel[attrkey] = "foo; SameSite=none" + with self.assertRaises(cookies.CookieError): + morsel.setdefault(attrkey, "foo; SameSite=none") + with self.assertRaises(cookies.CookieError): + morsel.update({attrkey: "foo; SameSite=none"}) + with self.assertRaises(cookies.CookieError): + morsel |= {attrkey: "foo; SameSite=none"} + + def test_semicolon_escaped_in_comment(self): + morsel = cookies.Morsel() + morsel.set("key", "value", "coded") + morsel["comment"] = "foo;SameSite=none;Domain=example.com" + self.assertEqual( + morsel.OutputString(), + r'key=coded; Comment="foo\073SameSite=none\073Domain=example.com"', + ) + def test_control_characters_output(self): # Tests that even if the internals of Morsel are modified # that a call to .output() has control character safeguards. Index: Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst 2026-11-25 21:44:57.138884072 +0100 @@ -0,0 +1,5 @@ +.. cve: CVE-2026-16052 + +:mod:`http.cookies` now raises :exc:`~http.cookies.CookieError` on any attempt +to set a value string that contains the reserved separator character ``;`` to +any attribute except :attr:`~http.cookies.Morsel.comment`. ++++++ CVE-2026-19552-ssl-get_server_certificate-check-hostname.patch ++++++ >From 46876c7d945f03826043bcaefb4c77fa8ea43602 Mon Sep 17 00:00:00 2001 From: Brett Smith <[email protected]> Date: Sat, 7 Nov 2026 14:07:53 -0500 Subject: [PATCH] [3.11] gh-161503: Check hostname in `ssl.get_server_certificate` with custom `ca_certs` (GH-161507) (cherry picked from commit 8dde46eaa6baf5f027a7234845b20d50b509624e) Co-authored-by: Brett Smith <[email protected]> --- Doc/library/ssl.rst | 8 +++++++- Lib/ssl.py | 4 +++- Lib/test/test_ssl.py | 8 ++++++-- .../2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst Index: Python-3.10.22/Doc/library/ssl.rst =================================================================== --- Python-3.10.22.orig/Doc/library/ssl.rst 2026-11-23 12:57:49.986268081 +0100 +++ Python-3.10.22/Doc/library/ssl.rst 2026-11-25 21:47:46.178224193 +0100 @@ -437,7 +437,8 @@ same format as used for the same parameter in :meth:`SSLContext.wrap_socket`. The call will attempt to validate the server certificate against that set of root certificates, and will fail - if the validation attempt fails. A timeout can be specified with the + if the validation attempt fails or the certificate hostname does not match + the server hostname. A timeout can be specified with the ``timeout`` parameter. .. versionchanged:: 3.3 @@ -450,6 +451,11 @@ .. versionchanged:: 3.10 The *timeout* parameter was added. + .. versionchanged:: next + The function now raises :exc:`SSLCertVerificationError` if *ca_certs* is + specified but the certificate hostname does not match the server + hostname. + .. function:: DER_cert_to_PEM_cert(DER_cert_bytes) Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded Index: Python-3.10.22/Lib/ssl.py =================================================================== --- Python-3.10.22.orig/Lib/ssl.py 2026-11-23 12:57:49.986824370 +0100 +++ Python-3.10.22/Lib/ssl.py 2026-11-25 21:47:46.179346679 +0100 @@ -1550,7 +1550,8 @@ ca_certs=None, timeout=_GLOBAL_DEFAULT_TIMEOUT): """Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. - If 'ca_certs' is specified, validate the server cert against it. + If 'ca_certs' is specified, validate the server cert against it and + check that it matches the hostname. If 'ssl_version' is specified, use it in the connection attempt. If 'timeout' is specified, use it in the connection attempt. """ @@ -1562,6 +1563,7 @@ cert_reqs = CERT_NONE context = _create_stdlib_context(ssl_version, cert_reqs=cert_reqs, + check_hostname=ca_certs is not None, cafile=ca_certs) with create_connection(addr, timeout=timeout) as sock: with context.wrap_socket(sock, server_hostname=host) as sslsock: Index: Python-3.10.22/Lib/test/test_ssl.py =================================================================== --- Python-3.10.22.orig/Lib/test/test_ssl.py 2026-11-23 12:57:49.988204374 +0100 +++ Python-3.10.22/Lib/test/test_ssl.py 2026-11-25 21:48:19.400444748 +0100 @@ -2423,6 +2423,10 @@ # independent test method _test_get_server_certificate_fail(self, *self.server_addr) + def test_get_server_certificate_fail_by_hostname(self): + _, port = self.server_addr + _test_get_server_certificate_fail(self, socket_helper.HOSTv4, port, SIGNING_CA) + def test_get_server_certificate_timeout(self): def servername_cb(ssl_sock, server_name, initial_context): time.sleep(0.2) @@ -2613,9 +2617,9 @@ if support.verbose: sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem)) -def _test_get_server_certificate_fail(test, host, port): +def _test_get_server_certificate_fail(test, host, port, ca_certs=CERTFILE): try: - pem = ssl.get_server_certificate((host, port), ca_certs=CERTFILE) + pem = ssl.get_server_certificate((host, port), ca_certs=ca_certs) except ssl.SSLError as x: #should fail if support.verbose: Index: Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ Python-3.10.22/Misc/NEWS.d/next/Security/2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst 2026-11-25 21:47:46.183151435 +0100 @@ -0,0 +1,4 @@ +.. cve: CVE-2026-19552 + +:func:`ssl.get_server_certificate` now verifies that the server hostname matches +its certificate when the caller specifies *ca_certs*. ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.D08nW3/_old 2026-11-28 23:25:38.802548652 +0100 +++ /var/tmp/diff_new_pack.D08nW3/_new 2026-11-28 23:25:38.806548819 +0100 @@ -1,6 +1,6 @@ -mtime: 1795456278 -commit: 1738bc9d9bfaa4e2d83086a00c650c7fa50dcf56180f2d43f3f208049eea47b5 +mtime: 1795642180 +commit: c174249903b605fe4a6f6865f646895dcf22fbdeda72261915611c74d8026f7d url: https://src.opensuse.org/python-interpreters/python310 -revision: 1738bc9d9bfaa4e2d83086a00c650c7fa50dcf56180f2d43f3f208049eea47b5 +revision: c174249903b605fe4a6f6865f646895dcf22fbdeda72261915611c74d8026f7d projectscmsync: https://src.opensuse.org/python-interpreters/_ObsPrj ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-11-25 22:29:40.000000000 +0100 @@ -0,0 +1,7 @@ +.osc +*.obscpio +*.osc +_build.* +.pbuild +*.rej +python310*-build/
