Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package patool for openSUSE:Factory checked in at 2026-11-13 18:31:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/patool (Old) and /work/SRC/openSUSE:Factory/.patool.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "patool" Fri Nov 13 18:31:48 2026 rev:5 rq:1397057 version:4.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/patool/patool.changes 2026-09-12 21:25:51.804809602 +0200 +++ /work/SRC/openSUSE:Factory/.patool.new.1251/patool.changes 2026-11-13 18:35:39.327123118 +0100 @@ -1,0 +2,11 @@ +Thu Nov 12 09:45:00 UTC 2026 - Martin Pluskal <[email protected]> + +- CVE-2026-124584: refuse symlink following and directory escape + in gzip extractor (boo#1289739) + * Sanitize embedded original filename, keep output inside outdir, + number instead of following pre-planted symlinks; Python path + opens with O_NOFOLLOW|O_EXCL. + * Add patool-CVE-2026-124584-gzip-symlink.patch + (no upstream fix yet). + +------------------------------------------------------------------- New: ---- patool-CVE-2026-124584-gzip-symlink.patch ----------(New B)---------- New: opens with O_NOFOLLOW|O_EXCL. * Add patool-CVE-2026-124584-gzip-symlink.patch (no upstream fix yet). ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ patool.spec ++++++ --- /var/tmp/diff_new_pack.LE0bSY/_old 2026-11-13 18:35:40.756183621 +0100 +++ /var/tmp/diff_new_pack.LE0bSY/_new 2026-11-13 18:35:40.761183833 +0100 @@ -25,6 +25,11 @@ License: GPL-3.0-or-later URL: https://github.com/wummel/patool Source: https://github.com/wummel/patool/releases/download/%{version}/patool-%{version}.tar.gz#/%{name}-%{version}.tar.gz +# Source-Binary-Exception: patool-4.1.0.tar.gz:patool-4.1.0/tests/data/* -- test-data: upstream archive fixtures only read by the test suite, never shipped +# CVE-2026-124584: refuse symlink following and directory escape in +# gzip extractor (embedded original filename). +# PATCH-FIX-OPENSUSE patool-CVE-2026-124584-gzip-symlink.patch [email protected] -- harden gzip/py_gzip extract paths, no upstream fix yet +Patch0: patool-CVE-2026-124584-gzip-symlink.patch BuildRequires: fdupes BuildRequires: python-rpm-macros BuildRequires: python3-base >= 3.12 @@ -54,7 +59,8 @@ It relies on helper applications to handle those archive formats. %prep -%autosetup -n patool-%{version} +%setup -q -n patool-%{version} +%autopatch -p1 %build %python3_build ++++++ patool-CVE-2026-124584-gzip-symlink.patch ++++++ --- a/patoolib/programs/gzip.py +++ b/patoolib/programs/gzip.py @@ -53,9 +53,41 @@ basearchive = os.path.basename(archive) # avoid overwriting the original archive with the same name if os.path.normcase(basefilename) != os.path.normcase(basearchive): - outfile = os.path.join(outdir, basefilename) + # CVE-2026-124584: sanitize the embedded name. basename + # strips any directory components so ../ cannot escape, + # but a pre-planted symlink at the target would still be + # followed by the shell redirection below. + basefilename = os.path.basename(basefilename) + if basefilename: + outfile = os.path.join(outdir, basefilename) except (OSError, subprocess.CalledProcessError) as err: log.log_error(f"could not run {cmd}: {err}") + return _secure_outfile(outdir, outfile) + + +def _secure_outfile(outdir, outfile): + """Keep outfile inside outdir and off existing files/symlinks. + + Returns a free path within outdir (numbering like + fileutil.get_single_outfile) or raises PatoolError on escape. + """ + from ..util import PatoolError + outdir_real = os.path.realpath(outdir) + # normpath collapses ../ so the containment check is meaningful; + # basename above already removed directory components. + outfile = os.path.normpath(outfile) + parent_real = os.path.realpath(os.path.dirname(outfile) or outdir) + if parent_real != outdir_real and not parent_real.startswith(outdir_real + os.sep): + raise PatoolError(f"refusing to extract outside of output directory: `{outfile}'") + if os.path.lexists(outfile): + # do not follow symlinks and do not overwrite: find a free name + base, ext = os.path.splitext(outfile) + i = 1 + candidate = f"{base}{i}{ext}" + while os.path.lexists(candidate): + i += 1 + candidate = f"{base}{i}{ext}" + outfile = candidate return outfile --- a/patoolib/programs/py_gzip.py +++ b/patoolib/programs/py_gzip.py @@ -16,6 +16,7 @@ # now gzip refers to the Python standard module, not the local one import gzip +import os from .. import fileutil, util READ_SIZE_BYTES = 1024 * 1024 @@ -23,10 +24,13 @@ def extract_gzip(archive, compression, cmd, verbosity, interactive, outdir): """Extract a GZIP archive with the gzip Python module.""" - targetname = fileutil.get_single_outfile(outdir, archive) + targetname = _secure_outfile(outdir, fileutil.get_single_outfile(outdir, archive)) try: + # O_NOFOLLOW|O_EXCL: never follow a raced symlink and never + # overwrite an existing file (CVE-2026-124584). + fd = os.open(targetname, os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_NOFOLLOW", 0), 0o666) with gzip.GzipFile(archive) as gzipfile: - with open(targetname, 'wb') as targetfile: + with os.fdopen(fd, 'wb') as targetfile: data = gzipfile.read(READ_SIZE_BYTES) while data: targetfile.write(data) @@ -52,3 +56,15 @@ except Exception as err: raise util.PatoolError(f"error creating {archive}") from err return + + +def _secure_outfile(outdir, targetname): + """Refuse escape and pre-existing symlinks (CVE-2026-124584).""" + outdir_real = os.path.realpath(outdir) + targetname = os.path.normpath(targetname) + parent_real = os.path.realpath(os.path.dirname(targetname) or outdir) + if parent_real != outdir_real and not parent_real.startswith(outdir_real + os.sep): + raise util.PatoolError(f"refusing to extract outside of output directory: `{targetname}'") + if os.path.lexists(targetname): + raise util.PatoolError(f"refusing to overwrite existing file `{targetname}'") + return targetname
