diff --git a/CVE-2007-4559-tarfile.patch b/CVE-2007-4559-tarfile.patch new file mode 100644 index 0000000000000000000000000000000000000000..5530e5ed44cf56cb5a18bcca8042617636216a3f --- /dev/null +++ b/CVE-2007-4559-tarfile.patch @@ -0,0 +1,47 @@ +Minimal patch for pip + +diff -rU3 pip-22.3.1-orig/src/pip/_internal/utils/unpacking.py pip-22.3.1/src/pip/_internal/utils/unpacking.py +--- a/pip/utils/__init__.py 2022-11-05 16:25:43.000000000 +0100 ++++ b/pip/utils/__init__.py 2023-08-08 13:17:47.705613554 +0200 +@@ -559,6 +559,13 @@ + if leading: + fn = split_leading_dir(fn)[1] + path = os.path.join(location, fn) ++ ++ # Call the `data` filter for its side effect (raising exception) ++ try: ++ tarfile.data_filter(member.replace(name=fn), location) ++ except tarfile.LinkOutsideDestinationError: ++ pass ++ + if member.isdir(): + ensure_dir(path) + elif member.issym(): + + +Patch for vendored distlib from https://github.com/pypa/distlib/pull/201 + +diff --git a/distlib/util.py b/distlib/util.py +index e0622e4..4349d0b 100644 +--- a/pip/_vendor/distlib/util.py ++++ b/pip/_vendor/distlib/util.py +@@ -1249,6 +1249,19 @@ def check_path(path): + for tarinfo in archive.getmembers(): + if not isinstance(tarinfo.name, text_type): + tarinfo.name = tarinfo.name.decode('utf-8') ++ ++ # Limit extraction of dangerous items, if this Python ++ # allows it easily. If not, just trust the input. ++ # See: https://docs.python.org/3/library/tarfile.html#extraction-filters ++ def extraction_filter(member, path): ++ """Run tarfile.tar_fillter, but raise the expected ValueError""" ++ # This is only called if the current Python has tarfile filters ++ try: ++ return tarfile.tar_filter(member, path) ++ except tarfile.FilterError as exc: ++ raise ValueError(str(exc)) ++ archive.extraction_filter = extraction_filter ++ + archive.extractall(dest_dir) + + finally: diff --git a/python-pip.spec b/python-pip.spec index 9f58a52d1667f0e34d40a37037d425391f4b22a6..2681318bb039494462827ee4678257df83a65855 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -15,7 +15,7 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! Version: 9.0.3 -Release: 22%{anolis_release}%{?dist} +Release: 23%{anolis_release}%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -130,6 +130,7 @@ Patch11: CVE-2021-3572.patch # https://www.python.org/dev/peps/pep-0592/ # Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2000135 Patch12: skip_yanked_releases.patch +Patch13: CVE-2007-4559-tarfile.patch Patch1000: 0001-add-pip-loongarch.conf.patch @@ -276,6 +277,7 @@ popd %endif %patch11 -p1 %patch12 -p1 +%patch13 -p1 %patch1000 -p1 @@ -392,6 +394,10 @@ py.test-%{python3_version} -m 'not network' %endif %changelog +* Mon Dec 18 2023 Kaiqiang Wang - 9.0.3-23.0.1 +- Use tarfile.data_filter for extracting (CVE-2007-4559, PEP-721, PEP-706) +- Resolves: RHBZ#2218241 + * Fri Jul 22 2022 huajingyun - 9.0.3-22.0.1 - Add pypi.loongnix.cn