[med-svn] [Git][med-team/invesalius][master] Fix CVE-2024-44825 (path traversal when opening .inv3 projects). Closes: #1136204.

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Nov 16 08:10:18 GMT 2026



Andreas Tille pushed to branch master at Debian Med / invesalius


Commits:
fb13bf73 by Valentín Torassa at 2026-11-15T10:12:18-03:00
Fix CVE-2024-44825 (path traversal when opening .inv3 projects). Closes: #1136204.

Backport upstream commit 61e92e0, which extracts every member of a project with tarfile's "data" filter.

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/fix-cve-2024-44825.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,13 @@
+invesalius (3.1.99998-9) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * fix-cve-2024-44825.patch: new: extract .inv3 projects with tarfile's
+    "data" filter, as upstream does since 61e92e0. A crafted project file
+    could otherwise write outside of the temporary project folder.
+    (CVE-2024-44825, Closes: #1136204)
+
+ -- Valentín Torassa <valentintorassacolombero at gmail.com>  Sun, 15 Nov 2026 10:12:18 -0300
+
 invesalius (3.1.99998-8) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/patches/fix-cve-2024-44825.patch
=====================================
@@ -0,0 +1,79 @@
+Description: Extract .inv3 projects with tarfile's "data" filter (CVE-2024-44825)
+ Extract() wrote every member of an .inv3 project to
+ os.path.join(folder, member name) without checking the name, so a crafted
+ project file could create or overwrite files outside of the temporary
+ project folder (CVE-2024-44825).
+ .
+ This backports upstream's rewrite of Extract(): every member goes through
+ tarfile's "data" extraction filter, a member that the filter rejects aborts
+ the extraction, and the returned file list is built from the filtered
+ names. The unused Extract_() is removed, as upstream did. The type hints
+ and the regression tests that upstream added in tests/test_project_extract.py
+ are left out: project.py in this version has no type hints, and the package
+ does not run upstream's test suite.
+Author: Paulo Henrique Junqueira Amorim <paulojamorim at gmail.com>
+Origin: backport, https://github.com/invesalius/invesalius3/commit/61e92e04f7d15686caad835f131e88f47635f0de
+Bug: https://github.com/invesalius/invesalius3/issues/1404
+Bug-Debian: https://bugs.debian.org/1136204
+Forwarded: not-needed
+Last-Update: 2026-11-15
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/invesalius/project.py
++++ b/invesalius/project.py
+@@ -488,32 +488,31 @@
+ 
+ 
+ def Extract(filename, folder):
++    """
++    Safely extracts an InVesalius project (.inv3) into folder.
++
++    Every member goes through tarfile's "data" extraction filter (PEP 706),
++    which strips leading "/" from names (so absolute names stay inside the
++    destination) and rejects paths escaping the destination (including
++    through previously extracted symlinks), absolute links or links pointing
++    outside the destination, device files, etc. A rejected member aborts the extraction
++    with a tarfile.FilterError (subclass of tarfile.TarError); there is no
++    unfiltered fallback (CVE-2024-44825).
++    """
++    if not hasattr(tarfile, "data_filter"):
++        raise RuntimeError(
++            "This Python version does not support safe tar extraction filters "
++            "(PEP 706). Please upgrade Python to open InVesalius projects."
++        )
+     if _has_win32api:
+         folder = win32api.GetShortPathName(folder)
+     folder = decode(folder, const.FS_ENCODE)
+-
+-    tar = tarfile.open(filename, "r")
+-    idir = decode(os.path.split(tar.getnames()[0])[0], 'utf8')
+-    os.mkdir(os.path.join(folder, idir))
+     filelist = []
+-    for t in tar.getmembers():
+-        fsrc = tar.extractfile(t)
+-        fname = os.path.join(folder, decode(t.name, 'utf-8'))
+-        fdst = open(fname, 'wb')
+-        shutil.copyfileobj(fsrc, fdst)
+-        filelist.append(fname)
+-        fsrc.close()
+-        fdst.close()
+-        del fsrc
+-        del fdst
+-    tar.close()
+-    return filelist
+-
+-
+-def Extract_(filename, folder):
+-    tar = tarfile.open(filename, "r:gz")
+-    #tar.list(verbose=True)
+-    tar.extractall(folder)
+-    filelist = [os.path.join(folder, i) for i in tar.getnames()]
+-    tar.close()
++    with tarfile.open(filename, "r") as tar:
++        for member in tar.getmembers():
++            # The filter may rewrite the member (e.g. strip a leading "/"), so
++            # the extracted path must be taken from the filtered member.
++            safe_member = tarfile.data_filter(member, folder)
++            tar.extract(safe_member, path=folder, filter="data")
++            filelist.append(os.path.join(folder, decode(safe_member.name, "utf-8")))
+     return filelist


=====================================
debian/patches/series
=====================================
@@ -8,3 +8,4 @@ python3.13
 fix-my-types.patch
 workaround-dropped-inner1d.patch
 fix-cve-2024-42845.patch
+fix-cve-2024-44825.patch



View it on GitLab: https://salsa.debian.org/med-team/invesalius/-/commit/fb13bf732ddb6303b90e19f932b6a30fe90cf929

-- 
View it on GitLab: https://salsa.debian.org/med-team/invesalius/-/commit/fb13bf732ddb6303b90e19f932b6a30fe90cf929
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261116/550eae86/attachment-0001.htm>


More information about the debian-med-commit mailing list