Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python313 for openSUSE:Factory checked in at 2026-12-01 16:57:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python313 (Old) and /work/SRC/openSUSE:Factory/.python313.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python313" Tue Dec 1 16:57:52 2026 rev:51 rq:1401511 version:3.13.18 Changes: -------- --- /work/SRC/openSUSE:Factory/python313/python313.changes 2026-11-25 16:12:39.047607841 +0100 +++ /work/SRC/openSUSE:Factory/.python313.new.1340718/python313.changes 2026-12-01 16:57:53.996421331 +0100 @@ -1,0 +2,29 @@ +Wed Nov 25 19:58:53 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-115791: gh-161705: Prevent shadowing stdlib in + gzip/tarfile/zipfile CLI (bsc#1290431) + CVE-2026-115791-archive-cli-prevent-shadowing.patch + +------------------------------------------------------------------- +Wed Nov 25 19:57:11 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-19552: gh-161503: 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 19:56:14 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-16052: gh-161707: Refuse ';' in all cookie + attributes except Comment (bsc#1290439) + CVE-2026-16052-cookies-refuse-semicolon.patch + +------------------------------------------------------------------- +Wed Nov 25 19:55:00 UTC 2026 - Matej Cepl <[email protected]> + +- CVE-2026-124249: gh-161569: Check cookie policy before + deleting expired cookies in http.cookiejar (bsc#1290433) + CVE-2026-124249-cookiejar-delete-expired.patch + +------------------------------------------------------------------- New: ---- CVE-2026-115791-archive-cli-prevent-shadowing.patch CVE-2026-124249-cookiejar-delete-expired.patch CVE-2026-16052-cookies-refuse-semicolon.patch CVE-2026-19552-ssl-get_server_certificate-hostname.patch ----------(New B)---------- New: gzip/tarfile/zipfile CLI (bsc#1290431) CVE-2026-115791-archive-cli-prevent-shadowing.patch New: deleting expired cookies in http.cookiejar (bsc#1290433) CVE-2026-124249-cookiejar-delete-expired.patch New: attributes except Comment (bsc#1290439) CVE-2026-16052-cookies-refuse-semicolon.patch New: (bsc#1290435) CVE-2026-19552-ssl-get_server_certificate-hostname.patch ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python313.spec ++++++ --- /var/tmp/diff_new_pack.RwT27e/_old 2026-12-01 16:57:55.442481857 +0100 +++ /var/tmp/diff_new_pack.RwT27e/_new 2026-12-01 16:57:55.444481940 +0100 @@ -251,6 +251,18 @@ # PATCH-FIX-UPSTREAM CVE-2026-103995-http-client-framing.patch bsc#1288328 [email protected] # gh-150751: validate http.client Content-Length and chunk-size Patch57: CVE-2026-103995-http-client-framing.patch +# PATCH-FIX-UPSTREAM CVE-2026-124249-cookiejar-delete-expired.patch bsc#1290433 [email protected] +# gh-161569: Check cookie policy before deleting expired cookies in http.cookiejar +Patch58: CVE-2026-124249-cookiejar-delete-expired.patch +# PATCH-FIX-UPSTREAM CVE-2026-16052-cookies-refuse-semicolon.patch bsc#1290439 [email protected] +# gh-161707: Refuse ';' in all cookie attributes except Comment +Patch59: CVE-2026-16052-cookies-refuse-semicolon.patch +# PATCH-FIX-UPSTREAM CVE-2026-19552-ssl-get_server_certificate-hostname.patch bsc#1290435 [email protected] +# gh-161503: Check hostname in ssl.get_server_certificate with custom ca_certs +Patch60: CVE-2026-19552-ssl-get_server_certificate-hostname.patch +# PATCH-FIX-UPSTREAM CVE-2026-115791-archive-cli-prevent-shadowing.patch bsc#1290431 [email protected] +# gh-161705: Prevent shadowing stdlib in gzip/tarfile/zipfile CLI +Patch61: CVE-2026-115791-archive-cli-prevent-shadowing.patch #### END OF PATCHES BuildRequires: autoconf-archive BuildRequires: automake ++++++ CVE-2026-115791-archive-cli-prevent-shadowing.patch ++++++ >From 4e1d94f1ea6ea92996b86c0efc8867e77962a16c 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. (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/test_runpy.py | 92 +++++++++++++++++++ Lib/test/test_sys.py | 9 ++ Lib/test/test_zipfile/test_core.py | 23 ++++- Lib/zipfile/__init__.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 + 14 files changed, 196 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.13.18/Doc/c-api/init_config.rst =================================================================== --- Python-3.13.18.orig/Doc/c-api/init_config.rst 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Doc/c-api/init_config.rst 2026-11-25 20:57:43.772232691 +0100 @@ -581,8 +581,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.13.18/Doc/library/sys.rst =================================================================== --- Python-3.13.18.orig/Doc/library/sys.rst 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Doc/library/sys.rst 2026-11-25 20:57:43.773232702 +0100 @@ -1394,6 +1394,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.13.18/Doc/using/cmdline.rst =================================================================== --- Python-3.13.18.orig/Doc/using/cmdline.rst 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Doc/using/cmdline.rst 2026-11-25 20:57:43.774232714 +0100 @@ -310,10 +310,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 @@ -341,14 +343,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. @@ -746,7 +742,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.13.18/Lib/gzip.py =================================================================== --- Python-3.13.18.orig/Lib/gzip.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/gzip.py 2026-11-25 20:57:43.775183387 +0100 @@ -643,6 +643,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.13.18/Lib/runpy.py =================================================================== --- Python-3.13.18.orig/Lib/runpy.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/runpy.py 2026-11-25 20:57:43.775728476 +0100 @@ -317,6 +317,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.13.18/Lib/tarfile.py =================================================================== --- Python-3.13.18.orig/Lib/tarfile.py 2026-11-22 00:12:05.495691663 +0100 +++ Python-3.13.18/Lib/tarfile.py 2026-11-25 20:57:43.776232736 +0100 @@ -3058,6 +3058,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.13.18/Lib/test/test_runpy.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_runpy.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/test/test_runpy.py 2026-11-25 20:57:43.777248984 +0100 @@ -20,6 +20,8 @@ requires_subprocess, verbose, ) +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, FakePath from test.support.script_helper import make_script, make_zip_script @@ -875,5 +877,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.13.18/Lib/test/test_sys.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_sys.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/test/test_sys.py 2026-11-25 20:57:43.778009499 +0100 @@ -1416,6 +1416,15 @@ def test_disable_gil_abi(self): self.assertEqual('t' in sys.abiflags, support.Py_GIL_DISABLED) + 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.13.18/Lib/test/test_zipfile/test_core.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_zipfile/test_core.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/test/test_zipfile/test_core.py 2026-11-25 20:57:43.779232769 +0100 @@ -49,6 +49,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): @@ -3674,17 +3684,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: @@ -3703,7 +3714,9 @@ except UnicodeEncodeError: self.skipTest(f'cannot encode file name {fn!a}') - 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.13.18/Lib/zipfile/__init__.py =================================================================== --- Python-3.13.18.orig/Lib/zipfile/__init__.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/zipfile/__init__.py 2026-11-25 20:57:43.780206114 +0100 @@ -2340,6 +2340,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.13.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.13.18/Misc/NEWS.d/next/Security/2026-11-07-15-56-47.gh-issue-161705.OjDK2d.rst 2026-11-25 20:57:43.780505699 +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.13.18/Modules/main.c =================================================================== --- Python-3.13.18.orig/Modules/main.c 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Modules/main.c 2026-11-25 20:57:43.781232792 +0100 @@ -178,6 +178,10 @@ return -1; } + if (PyDict_SetItemString(sysdict, "_path0", path0) < 0) { + return -1; + } + if (PyList_Insert(sys_path, 0, path0)) { return -1; } Index: Python-3.13.18/Python/pathconfig.c =================================================================== --- Python-3.13.18.orig/Python/pathconfig.c 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Python/pathconfig.c 2026-11-25 20:57:43.782232803 +0100 @@ -357,7 +357,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.13.18/Python/sysmodule.c =================================================================== --- Python-3.13.18.orig/Python/sysmodule.c 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Python/sysmodule.c 2026-11-25 20:57:43.783232814 +0100 @@ -3702,6 +3702,8 @@ SET_SYS("path_importer_cache", PyDict_New()); SET_SYS("path_hooks", PyList_New(0)); + SET_SYS("_path0", Py_None); + if (_PyErr_Occurred(tstate)) { goto err_occurred; } ++++++ CVE-2026-124249-cookiejar-delete-expired.patch ++++++ >From 76a88d2e4d8c86af4cd2fdde2284a0bc1c3e4f26 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.13.18/Lib/http/cookiejar.py =================================================================== --- Python-3.13.18.orig/Lib/http/cookiejar.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/http/cookiejar.py 2026-11-25 20:54:17.970933820 +0100 @@ -1565,28 +1565,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.13.18/Lib/test/test_http_cookiejar.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_http_cookiejar.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/test/test_http_cookiejar.py 2026-11-25 20:54:17.973173136 +0100 @@ -736,6 +736,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.13.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.13.18/Misc/NEWS.d/next/Security/2026-11-07-01-43-49.gh-issue-161569.cookiej.rst 2026-11-25 20:54:17.974382538 +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-cookies-refuse-semicolon.patch ++++++ >From 47a9125aad1c94e875a8b9665fe720092087dadd Mon Sep 17 00:00:00 2001 From: Brett Smith <[email protected]> Date: Thu, 12 Nov 2026 10:50:42 -0500 Subject: [PATCH] [3.13] 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.13.18/Doc/library/http.cookies.rst =================================================================== --- Python-3.13.18.orig/Doc/library/http.cookies.rst 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Doc/library/http.cookies.rst 2026-11-25 20:55:38.706120197 +0100 @@ -168,6 +168,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 @@ -227,6 +232,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) @@ -241,6 +250,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.13.18/Lib/http/cookies.py =================================================================== --- Python-3.13.18.orig/Lib/http/cookies.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/http/cookies.py 2026-11-25 20:55:38.706729236 +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.13.18/Lib/test/test_http_cookies.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_http_cookies.py 2026-10-25 19:31:23.000000000 +0100 +++ Python-3.13.18/Lib/test/test_http_cookies.py 2026-11-25 20:55:38.707232736 +0100 @@ -616,6 +616,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.13.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.13.18/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst 2026-11-25 20:55:38.707487877 +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 884a60492cd7a975a46f1274c691ce3d40faf50d Mon Sep 17 00:00:00 2001 From: Brett Smith <[email protected]> Date: Sat, 7 Nov 2026 14:07:53 -0500 Subject: [PATCH] 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.13.18/Doc/library/ssl.rst =================================================================== --- Python-3.13.18.orig/Doc/library/ssl.rst 2026-11-20 17:39:44.055847754 +0100 +++ Python-3.13.18/Doc/library/ssl.rst 2026-11-25 20:56:44.103566172 +0100 @@ -394,7 +394,8 @@ same format as used for the *cafile* parameter in :meth:`SSLContext.load_verify_locations`. 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 @@ -407,6 +408,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.13.18/Lib/ssl.py =================================================================== --- Python-3.13.18.orig/Lib/ssl.py 2026-11-20 17:39:44.055847754 +0100 +++ Python-3.13.18/Lib/ssl.py 2026-11-25 20:56:44.105621730 +0100 @@ -1518,7 +1518,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. """ @@ -1530,6 +1531,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.13.18/Lib/test/test_ssl.py =================================================================== --- Python-3.13.18.orig/Lib/test/test_ssl.py 2026-11-20 17:39:44.055847754 +0100 +++ Python-3.13.18/Lib/test/test_ssl.py 2026-11-25 20:56:44.107055194 +0100 @@ -2503,6 +2503,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) @@ -2693,10 +2697,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.13.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.13.18/Misc/NEWS.d/next/Security/2026-11-06-16-22-47.gh-issue-161503.FkIl87.rst 2026-11-25 20:56:44.107704870 +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.RwT27e/_old 2026-12-01 16:57:55.584487800 +0100 +++ /var/tmp/diff_new_pack.RwT27e/_new 2026-12-01 16:57:55.586487884 +0100 @@ -1,6 +1,6 @@ -mtime: 1795471038 -commit: 5daeef7fd78f9cea628916e3439bc2e2860c50be8880c23d5eb51a2d29e1a0f7 +mtime: 1795636749 +commit: 50369a6761af021b9ad47df6757bf9f356de45b427874ea50477a3eeeaafa395 url: https://src.opensuse.org/python-interpreters/python313 -revision: 5daeef7fd78f9cea628916e3439bc2e2860c50be8880c23d5eb51a2d29e1a0f7 +revision: 50369a6761af021b9ad47df6757bf9f356de45b427874ea50477a3eeeaafa395 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 20:59:09.000000000 +0100 @@ -0,0 +1,6 @@ +.osc +*.obscpio +*.osc +_build.* +.pbuild +python313-*-build/
