public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Alejandro Alvarez Ayllon <a.alvarezayllon@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/onnx] test-1.21.0: Backport of fix for CVE-2024-5187
Date: Mon, 08 Jun 2026 15:18:22 GMT	[thread overview]
Message-ID: <178093190229.1.12970833761617478671.rpms-onnx-2f10ec013d88@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/onnx
Branch : test-1.21.0
Commit : 2f10ec013d888d4bf63a78706ac69e595b9af408
Author : Alejandro Alvarez Ayllon <a.alvarezayllon@gmail.com>
Date   : 2024-07-02T09:59:17+00:00
Stats  : +92/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/onnx/c/2f10ec013d888d4bf63a78706ac69e595b9af408?branch=test-1.21.0

Log:
Backport of fix for CVE-2024-5187

---
diff --git a/0007-Mitigate-tarball-directory-traversal-risks-6164.patch b/0007-Mitigate-tarball-directory-traversal-risks-6164.patch
new file mode 100644
index 0000000..b64086b
--- /dev/null
+++ b/0007-Mitigate-tarball-directory-traversal-risks-6164.patch
@@ -0,0 +1,86 @@
+From dd0a5b8b4ede6b27a51f571bb5587e075b8b1c20 Mon Sep 17 00:00:00 2001
+From: sunflowersxu <166728538+sunflowersxu@users.noreply.github.com>
+Date: Thu, 13 Jun 2024 01:47:14 +0800
+Subject: [PATCH 7/7] Mitigate tarball directory traversal risks (#6164)
+
+Hi, this pr is cleaner version than #6145
+
+Signed-off-by: sunriseXu <15927176697@163.com>
+Co-authored-by: sunriseXu <15927176697@163.com>
+Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
+(cherry picked from commit 3fc3845edb048df559aa2a839e39e95503a0ee34)
+---
+ onnx/hub.py | 43 ++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 42 insertions(+), 1 deletion(-)
+
+diff --git a/onnx/hub.py b/onnx/hub.py
+index e5ca9e2c..d27bbc78 100644
+--- a/onnx/hub.py
++++ b/onnx/hub.py
+@@ -271,6 +271,35 @@ def load(
+     return onnx.load(cast(IO[bytes], BytesIO(model_bytes)))
+ 
+ 
++def _tar_members_filter(tar: tarfile.TarFile, base: str) -> list[tarfile.TarInfo]:
++    """Check that the content of ``tar`` will be extracted safely
++
++    Args:
++        tar: The tarball file
++        base: The directory where the tarball will be extracted
++
++    Returns:
++        list of tarball members
++    """
++    result = []
++    for member in tar:
++        member_path = os.path.join(base, member.name)
++        abs_base = os.path.abspath(base)
++        abs_member = os.path.abspath(member_path)
++        if not abs_member.startswith(abs_base):
++            raise RuntimeError(
++                f"The tarball member {member_path} in downloading model contains "
++                f"directory traversal sequence which may contain harmful payload."
++            )
++        elif member.issym() or member.islnk():
++            raise RuntimeError(
++                f"The tarball member {member_path} in downloading model contains "
++                f"symbolic links which may contain harmful payload."
++            )
++        result.append(member)
++    return result
++
++
+ def download_model_with_test_data(
+     model: str,
+     repo: str = "onnx/models:main",
+@@ -280,6 +309,7 @@ def download_model_with_test_data(
+ ) -> Optional[str]:
+     """
+     Downloads a model along with test data by name from the onnx model hub and returns the directory to which the files have been extracted.
++    Users are responsible for making sure the model comes from a trusted source, and the data is safe to be extracted.
+ 
+     :param model: The name of the onnx model in the manifest. This field is case-sensitive
+     :param repo: The location of the model repo in format "user/repo[:branch]".
+@@ -342,7 +372,18 @@ def download_model_with_test_data(
+         local_model_with_data_dir_path = local_model_with_data_path[
+             0 : len(local_model_with_data_path) - 7
+         ]
+-        model_with_data_zipped.extractall(local_model_with_data_dir_path)
++        # Mitigate tarball directory traversal risks
++        if hasattr(tarfile, "data_filter"):
++            model_with_data_zipped.extractall(
++                path=local_model_with_data_dir_path, filter="data"
++            )
++        else:
++            model_with_data_zipped.extractall(
++                path=local_model_with_data_dir_path,
++                members=_tar_members_filter(
++                    model_with_data_zipped, local_model_with_data_dir_path
++                ),
++            )
+     model_with_data_path = (
+         local_model_with_data_dir_path
+         + "/"
+-- 
+2.45.2
+

diff --git a/onnx.spec b/onnx.spec
index 98ab4df..4b9da34 100644
--- a/onnx.spec
+++ b/onnx.spec
@@ -1,6 +1,6 @@
 Name:       onnx
 Version:    1.15.0
-Release:    2%{?dist}
+Release:    3%{?dist}
 Summary:    Open standard for machine learning interoperability
 License:    Apache-2.0
 
@@ -20,6 +20,8 @@ Patch4:     0004-Add-fixes-for-use-with-onnxruntime.patch
 Patch5:     0005-Fix-path-sanitization-bypass-leading-to-arbitrary-re.patch
 # Backport of fix for CVE-2024-27319
 Patch6:     0006-Fix-Out-of-bounds-read-due-to-lack-of-string-termina.patch
+# Backport of fix for CVE-2024-5187
+Patch7:     0007-Mitigate-tarball-directory-traversal-risks-6164.patch
 
 # https://bugzilla.redhat.com/show_bug.cgi?id=2212096
 ExcludeArch:    s390x
@@ -114,6 +116,9 @@ export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
 %{_bindir}/check-node
 
 %changelog
+* Tue Jul 02 2024 Alejandro Alvarez Ayllon <a.alvarezayllon@gmail.com> - 1.15.0-3
+- Backport of fix for CVE-2024-5187
+
 * Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 1.15.0-2
 - Rebuilt for Python 3.13
 

                 reply	other threads:[~2026-06-08 15:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178093190229.1.12970833761617478671.rpms-onnx-2f10ec013d88@fedoraproject.org \
    --to=a.alvarezayllon@gmail.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox