Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python311 for openSUSE:Factory checked in at 2026-11-30 14:24:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python311 (Old) and /work/SRC/openSUSE:Factory/.python311.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python311" Mon Nov 30 14:24:35 2026 rev:79 rq:1401213 version:3.11.18 Changes: -------- --- /work/SRC/openSUSE:Factory/python311/python311.changes 2026-11-25 16:12:44.747849688 +0100 +++ /work/SRC/openSUSE:Factory/.python311.new.1340718/python311.changes 2026-11-30 14:25:55.471730900 +0100 @@ -1,0 +2,28 @@ +Wed Nov 25 20:39:24 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.patch + +------------------------------------------------------------------- +Wed Nov 25 20:38:26 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-hostname.patch + +------------------------------------------------------------------- +Wed Nov 25 20:37:33 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-16052: Refuse ';' in all cookie attributes except + Comment (bsc#1290439) + CVE-2026-16052-Morsel-refuse-semicolon.patch + +------------------------------------------------------------------- +Wed Nov 25 20:36:20 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 + +------------------------------------------------------------------- @@ -45,0 +74 @@ + New: ---- CVE-2026-115791-prevent-shadowing-stdlib.patch CVE-2026-124249-cookiejar-expired-cookie-policy.patch CVE-2026-16052-Morsel-refuse-semicolon.patch CVE-2026-19552-ssl-get_server_certificate-hostname.patch ----------(New B)---------- New: CLI (bsc#1290431) CVE-2026-115791-prevent-shadowing-stdlib.patch New: cookies in http.cookiejar (bsc#1290433) CVE-2026-124249-cookiejar-expired-cookie-policy.patch New: Comment (bsc#1290439) CVE-2026-16052-Morsel-refuse-semicolon.patch New: with custom ca_certs (bsc#1290435) CVE-2026-19552-ssl-get_server_certificate-hostname.patch ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python311.spec ++++++ --- /var/tmp/diff_new_pack.u7PXrM/_old 2026-11-30 14:25:59.263890835 +0100 +++ /var/tmp/diff_new_pack.u7PXrM/_new 2026-11-30 14:25:59.265890920 +0100 @@ -212,6 +212,18 @@ # PATCH-FIX-UPSTREAM CVE-2026-103995-validate-http.client-Content-Length-chunk-size.patch bsc#1288328 [email protected] # Validate http.client Content-Length and chunk-size Patch60: CVE-2026-103995-validate-http.client-Content-Length-chunk-size.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 +Patch61: CVE-2026-124249-cookiejar-expired-cookie-policy.patch +# PATCH-FIX-UPSTREAM CVE-2026-16052-Morsel-refuse-semicolon.patch bsc#1290439 [email protected] +# Refuse ';' in all cookie attributes except Comment +Patch62: CVE-2026-16052-Morsel-refuse-semicolon.patch +# PATCH-FIX-UPSTREAM CVE-2026-19552-ssl-get_server_certificate-hostname.patch bsc#1290435 [email protected] +# Check hostname in ssl.get_server_certificate with custom ca_certs +Patch63: CVE-2026-19552-ssl-get_server_certificate-hostname.patch +# PATCH-FIX-UPSTREAM CVE-2026-115791-prevent-shadowing-stdlib.patch bsc#1290431 [email protected] +# Prevent shadowing stdlib in gzip/tarfile/zipfile CLI +Patch64: CVE-2026-115791-prevent-shadowing-stdlib.patch ### END OF PATCHES BuildRequires: autoconf-archive BuildRequires: automake ++++++ CVE-2026-115791-prevent-shadowing-stdlib.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) --- Doc/c-api/init_config.rst | 4 +- Doc/library/sys.rst | 18 ++++ Doc/using/cmdline.rst | 24 +++-- Lib/gzip.py | 5 + Lib/runpy.py | 20 ++++ Lib/tarfile.py | 4 + Lib/test/support/__init__.py | 10 ++ Lib/test/test_runpy.py | 92 +++++++++++++++++++ Lib/test/test_sys.py | 9 ++ Lib/test/test_zipfile.py | 23 ++++- Lib/zipfile.py | 4 + ...-11-07-15-56-47.gh-issue-161705.OjDK2d.rst | 6 ++ Modules/main.c | 4 + Python/pathconfig.c | 2 +- Python/sysmodule.c | 2 + 15 files changed, 206 insertions(+), 21 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst Index: Python-3.11.18/Doc/c-api/init_config.rst =================================================================== --- Python-3.11.18.orig/Doc/c-api/init_config.rst 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Doc/c-api/init_config.rst 2026-11-25 21:39:02.332344958 +0100 @@ -561,8 +561,8 @@ .. c:member:: int safe_path - If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to - :data:`sys.path` at startup: + If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe + :data:`sys._path0` to :data:`sys.path` at startup: * If :c:member:`argv[0] <PyConfig.argv>` is equal to ``L"-m"`` (``python -m module``), prepend the current working directory. Index: Python-3.11.18/Doc/library/sys.rst =================================================================== --- Python-3.11.18.orig/Doc/library/sys.rst 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Doc/library/sys.rst 2026-11-25 21:39:02.333252208 +0100 @@ -1279,6 +1279,24 @@ * Module :mod:`site` This describes how to use .pth files to extend :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:`-P` or :option:`-I` command line options are used or if + :envvar:`PYTHONSAFEPATH` environment variable 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 Index: Python-3.11.18/Doc/using/cmdline.rst =================================================================== --- Python-3.11.18.orig/Doc/using/cmdline.rst 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Doc/using/cmdline.rst 2026-11-25 21:39:02.334317174 +0100 @@ -300,10 +300,12 @@ Run Python in isolated mode. This also implies :option:`-E`, :option:`-P` and :option:`-s` options. - In isolated mode :data:`sys.path` contains neither the script's directory nor - the user's site-packages directory. All ``PYTHON*`` environment - variables are ignored, too. Further restrictions may be imposed to prevent - the user from injecting malicious code. + In isolated mode, Python does not prepend the potentially unsafe path + :data:`sys._path0` to :data:`sys.path`, and ignores all ``PYTHON*`` + environment variables, e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, + that might be set. + Further restrictions may be imposed to prevent the user from injecting + malicious code. .. versionadded:: 3.4 @@ -331,14 +333,8 @@ .. option:: -P - Don't prepend a potentially unsafe path to :data:`sys.path`: - - * ``python -m module`` command line: Don't prepend the current working - directory. - * ``python script.py`` command line: Don't prepend the script's directory. - If it's a symbolic link, resolve symbolic links. - * ``python -c code`` and ``python`` (REPL) command lines: Don't prepend an - empty string, which means the current working directory. + Don't prepend the potentially unsafe path :data:`sys._path0` to + :data:`sys.path`. See also the :envvar:`PYTHONSAFEPATH` environment variable, and :option:`-E` and :option:`-I` (isolated) options. @@ -635,7 +631,9 @@ .. envvar:: PYTHONSAFEPATH If this is set to a non-empty string, don't prepend a potentially unsafe - path to :data:`sys.path`: see the :option:`-P` option for details. + path :data:`sys._path0` to :data:`sys.path`. + + See also the :option:`-P` option. .. versionadded:: 3.11 Index: Python-3.11.18/Lib/gzip.py =================================================================== --- Python-3.11.18.orig/Lib/gzip.py 2026-11-06 17:19:06.484795364 +0100 +++ Python-3.11.18/Lib/gzip.py 2026-11-25 21:39:02.334845941 +0100 @@ -618,6 +618,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.") Index: Python-3.11.18/Lib/runpy.py =================================================================== --- Python-3.11.18.orig/Lib/runpy.py 2026-11-06 17:19:07.483452316 +0100 +++ Python-3.11.18/Lib/runpy.py 2026-11-25 21:39:02.335516755 +0100 @@ -314,6 +314,26 @@ pass +def _remove_sys_path0(): + """ + Remove sys._path0 from sys.path. Do nothing if sys._path0 is + sys._stdlib_dir or if it has already been removed. Similar to using -P + (safe path) command line option. + """ + path0 = sys._path0 + if path0 is None: + return + + if path0 == sys._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: Index: Python-3.11.18/Lib/tarfile.py =================================================================== --- Python-3.11.18.orig/Lib/tarfile.py 2026-11-06 17:19:07.555435126 +0100 +++ Python-3.11.18/Lib/tarfile.py 2026-11-25 21:39:02.336078664 +0100 @@ -2974,6 +2974,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) Index: Python-3.11.18/Lib/test/support/__init__.py =================================================================== --- Python-3.11.18.orig/Lib/test/support/__init__.py 2026-11-06 19:23:03.618422176 +0100 +++ Python-3.11.18/Lib/test/support/__init__.py 2026-11-25 21:39:02.337227067 +0100 @@ -2299,3 +2299,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 Index: Python-3.11.18/Lib/test/test_runpy.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_runpy.py 2026-11-06 17:19:09.042441818 +0100 +++ Python-3.11.18/Lib/test/test_runpy.py 2026-11-25 21:39:02.337958646 +0100 @@ -13,6 +13,8 @@ import unittest import warnings from test.support import no_tracing, verbose, requires_subprocess, requires_resource +from test import support +from test.support import os_helper from test.support.import_helper import forget, make_legacy_pyc, unload from test.support.os_helper import create_empty_file, temp_dir from test.support.script_helper import make_script, make_zip_script @@ -835,5 +837,95 @@ self.assertSigInt(["-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 = '/to/stdlib' + OTHER_PATH = '/other/path' + sys_path = [PATH0, STDLIB_PATH, PATH0, '', OTHER_PATH, PATH0] + expected = [STDLIB_PATH, '', OTHER_PATH] + with (support.swap_attr(sys, '_stdlib_dir', STDLIB_PATH), + 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 sys._stdlib_dir + sys_path = ['', STDLIB_PATH, OTHER_PATH] + expected = sys_path.copy() + with (support.swap_attr(sys, '_stdlib_dir', STDLIB_PATH), + 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, '_stdlib_dir', STDLIB_PATH), + 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 + proc = subprocess.run(cmd, text=True, stderr=subprocess.PIPE, env=env) + self.assertEqual(proc.returncode, 0, proc.stderr) + + @support.requires_subprocess() + def test_remove_sys_path0_run_python(self): + 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 sys.flags.safe_path: + 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('-P', '-c', CODE) + + 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('-P', filename) + + with os_helper.change_cwd(tmpdir): + # Test "python -m module" + self.run_python('-m', name) + self.run_python('-P', '-m', name, PYTHONPATH=tmpdir) + + if __name__ == "__main__": unittest.main() Index: Python-3.11.18/Lib/test/test_sys.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_sys.py 2026-11-06 17:19:09.191451203 +0100 +++ Python-3.11.18/Lib/test/test_sys.py 2026-11-25 21:39:02.338618269 +0100 @@ -1186,6 +1186,15 @@ self.assertEqual(os.path.normpath(sys._stdlib_dir), os.path.normpath(expected)) + 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 UnraisableHookTest(unittest.TestCase): Index: Python-3.11.18/Lib/test/test_zipfile.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_zipfile.py 2026-11-06 17:19:09.691806517 +0100 +++ Python-3.11.18/Lib/test/test_zipfile.py 2026-11-25 21:39:02.340098869 +0100 @@ -51,6 +51,16 @@ yield f test.assertFalse(f.closed) + [email protected] +def save_restore_sys_path(): + old_path = sys.path.copy() + try: + yield + finally: + sys.path[:] = old_path + + class AbstractTestsWithSourceFile: @classmethod def setUpClass(cls): @@ -4017,17 +4027,18 @@ def test_cli_with_metadata_encoding(self): errmsg = "Non-conforming encodings not supported with -c." args = ["--metadata-encoding=shift_jis", "-c", "nonesuch", "nonesuch"] - with captured_stdout() as stdout: - with captured_stderr() as stderr: + with (captured_stdout() as stdout, + captured_stderr() as stderr, + save_restore_sys_path()): self.assertRaises(SystemExit, zipfile.main, args) self.assertEqual(stdout.getvalue(), "") self.assertIn(errmsg, stderr.getvalue()) - with captured_stdout() as stdout: + with captured_stdout() as stdout, save_restore_sys_path(): zipfile.main(["--metadata-encoding=shift_jis", "-t", TESTFN]) listing = stdout.getvalue() - with captured_stdout() as stdout: + with captured_stdout() as stdout, save_restore_sys_path(): zipfile.main(["--metadata-encoding=shift_jis", "-l", TESTFN]) listing = stdout.getvalue() for name in self.file_names: @@ -4046,7 +4057,9 @@ except UnicodeEncodeError: self.skipTest(f'cannot encode file name {fn!r}') - zipfile.main(["--metadata-encoding=shift_jis", "-e", TESTFN, TESTFN2]) + with save_restore_sys_path(): + zipfile.main(["--metadata-encoding=shift_jis", "-e", + TESTFN, TESTFN2]) listing = os.listdir(TESTFN2) for name in self.file_names: self.assertIn(name, listing) Index: Python-3.11.18/Lib/zipfile.py =================================================================== --- Python-3.11.18.orig/Lib/zipfile.py 2026-11-06 17:19:10.160246927 +0100 +++ Python-3.11.18/Lib/zipfile.py 2026-11-25 21:39:02.341299441 +0100 @@ -2570,6 +2570,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) Index: Python-3.11.18/Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ Python-3.11.18/Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst 2026-11-25 21:39:02.341758466 +0100 @@ -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. Index: Python-3.11.18/Modules/main.c =================================================================== --- Python-3.11.18.orig/Modules/main.c 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Modules/main.c 2026-11-25 21:39:02.342525859 +0100 @@ -174,6 +174,10 @@ return -1; } + if (PyDict_SetItemString(sysdict, "_path0", path0) < 0) { + return -1; + } + if (PyList_Insert(sys_path, 0, path0)) { return -1; } Index: Python-3.11.18/Python/pathconfig.c =================================================================== --- Python-3.11.18.orig/Python/pathconfig.c 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Python/pathconfig.c 2026-11-25 21:39:02.344389865 +0100 @@ -380,7 +380,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. Index: Python-3.11.18/Python/sysmodule.c =================================================================== --- Python-3.11.18.orig/Python/sysmodule.c 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Python/sysmodule.c 2026-11-25 21:39:02.345138626 +0100 @@ -3018,6 +3018,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.11.18/Lib/http/cookiejar.py =================================================================== --- Python-3.11.18.orig/Lib/http/cookiejar.py 2026-11-06 17:19:06.507074328 +0100 +++ Python-3.11.18/Lib/http/cookiejar.py 2026-11-25 21:35:23.227561030 +0100 @@ -1563,28 +1563,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.11.18/Lib/test/test_http_cookiejar.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_http_cookiejar.py 2026-11-06 17:19:08.401853696 +0100 +++ Python-3.11.18/Lib/test/test_http_cookiejar.py 2026-11-25 21:35:23.229561048 +0100 @@ -708,6 +708,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.11.18/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.11.18/Misc/NEWS.d/next/Security/2026-11-07-01-43-49.gh-issue-161569.cookiej.rst 2026-11-25 21:35:23.231886471 +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-Morsel-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.11.18/Doc/library/http.cookies.rst =================================================================== --- Python-3.11.18.orig/Doc/library/http.cookies.rst 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Doc/library/http.cookies.rst 2026-11-25 21:37:11.459546749 +0100 @@ -165,6 +165,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 @@ -224,6 +229,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) @@ -238,6 +247,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.11.18/Lib/http/cookies.py =================================================================== --- Python-3.11.18.orig/Lib/http/cookies.py 2026-11-06 19:23:03.820959167 +0100 +++ Python-3.11.18/Lib/http/cookies.py 2026-11-25 21:37:11.461637972 +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.11.18/Lib/test/test_http_cookies.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_http_cookies.py 2026-11-06 19:23:03.821292204 +0100 +++ Python-3.11.18/Lib/test/test_http_cookies.py 2026-11-25 21:37:11.462712968 +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.11.18/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.11.18/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst 2026-11-25 21:37:11.463254719 +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-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.11.18/Doc/library/ssl.rst =================================================================== --- Python-3.11.18.orig/Doc/library/ssl.rst 2026-10-25 20:41:29.000000000 +0100 +++ Python-3.11.18/Doc/library/ssl.rst 2026-11-25 21:38:06.393031818 +0100 @@ -438,7 +438,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 @@ -451,6 +452,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.11.18/Lib/ssl.py =================================================================== --- Python-3.11.18.orig/Lib/ssl.py 2026-11-06 17:19:07.528022136 +0100 +++ Python-3.11.18/Lib/ssl.py 2026-11-25 21:38:06.395207884 +0100 @@ -1560,7 +1560,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. """ @@ -1572,6 +1573,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.11.18/Lib/test/test_ssl.py =================================================================== --- Python-3.11.18.orig/Lib/test/test_ssl.py 2026-11-06 19:33:07.282695414 +0100 +++ Python-3.11.18/Lib/test/test_ssl.py 2026-11-25 21:38:06.396341681 +0100 @@ -2466,6 +2466,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) @@ -2654,10 +2658,10 @@ 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): with warnings_helper.check_no_resource_warning(test): 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.11.18/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.11.18/Misc/NEWS.d/next/Security/2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst 2026-11-25 21:38:06.396970416 +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.u7PXrM/_old 2026-11-30 14:25:59.439898259 +0100 +++ /var/tmp/diff_new_pack.u7PXrM/_new 2026-11-30 14:25:59.442898385 +0100 @@ -1,6 +1,6 @@ -mtime: 1795433661 -commit: c22c9109afb7f443c87f90497818a5a0ed722a1f5c9cf866f2b94d43bdc89936 +mtime: 1795639176 +commit: ecfc051a51c47689a9b57c67a0d4548a615723ee6b397aead030ae250d6a0510 url: https://src.opensuse.org/python-interpreters/python311 -revision: c22c9109afb7f443c87f90497818a5a0ed722a1f5c9cf866f2b94d43bdc89936 +revision: ecfc051a51c47689a9b57c67a0d4548a615723ee6b397aead030ae250d6a0510 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 21:39:36.000000000 +0100 @@ -0,0 +1,7 @@ +_build.* +*.obscpio +*.osc +.osc +.pbuild +python311*-build/ +*.rej
