Hi,
I prepared a fix for CVE-2026-41140 (path traversal in sdist extraction)
for poetry in bookworm, currently marked no-dsa. It is a backport of
upstream commit e512e7fc.
Tested in a bookworm chroot: the package builds and the build-time tests
pass; crafted sdists ("../", outside symlink, outside hardlink) write
outside the extraction directory with 1.3.2+dfsg-3 and are refused with
the fix; autopkgtest shows no regressions (the same two
test_info_setup_complex* failures happen with 1.3.2+dfsg-3).
The Release Team pointed me to you (bookworm-pu bug #1154617).
Branch:
https://salsa.debian.org/python-team/packages/poetry/-/tree/debian/bookworm
Debdiff attached.
Should I upload it to bookworm-security and prepare the DLA, or would
you prefer to handle it?
Nico
--
⠀⢀⣴⣾⠿⠿⣿⣶⣄⠀ Nico Della Torre (nicoz)
⢠⣿⠋⠀⣠⢄⠀⠙⣿⣇ Debian Maintainer · Ubuntu
⢾⡇⠀⣾⠀⠀⠀⢀⣿⡟ https://wiki.debian.org/nicoz
⠘⣇⠀⠘⢷⣶⣶⣾⠟⠁ IRC: nicoz @ OFTC, Libera.Chat
⠀⠈⠣⢄⠀⠀⠀⠀⠀⠀ GPG: 0456 E8BC 1DC0 B027 EF8D 66A6 9549 3787 F6F1 9F03
diff -Nru poetry-1.3.2+dfsg/debian/changelog poetry-1.3.2+dfsg/debian/changelog
--- poetry-1.3.2+dfsg/debian/changelog 2023-01-17 22:59:26.000000000 +0100
+++ poetry-1.3.2+dfsg/debian/changelog 2026-11-20 12:00:00.000000000 +0100
@@ -1,3 +1,11 @@
+poetry (1.3.2+dfsg-3+deb12u1) bookworm; urgency=medium
+
+ * Team upload.
+ * Backport upstream commit e512e7fc: refuse to write files outside the
+ target directory during sdist extraction (CVE-2026-41140)
+
+ -- Nico Della Torre <[email protected]> Fri, 20 Nov 2026 12:00:00 +0100
+
poetry (1.3.2+dfsg-3) unstable; urgency=medium
* d/control: Remove python3-pylev as a B-Depends. This is a B-Depends of
diff -Nru
poetry-1.3.2+dfsg/debian/patches/CVE-2026-41140-refuse-path-traversal-in-sdist-extraction.patch
poetry-1.3.2+dfsg/debian/patches/CVE-2026-41140-refuse-path-traversal-in-sdist-extraction.patch
---
poetry-1.3.2+dfsg/debian/patches/CVE-2026-41140-refuse-path-traversal-in-sdist-extraction.patch
1970-01-01 01:00:00.000000000 +0100
+++
poetry-1.3.2+dfsg/debian/patches/CVE-2026-41140-refuse-path-traversal-in-sdist-extraction.patch
2026-11-20 12:00:00.000000000 +0100
@@ -0,0 +1,81 @@
+From: Randy Döring <[email protected]>
+Date: Sun, 12 Apr 2026 16:50:20 +0200
+Subject: refuse to write files outside the target directory during sdist
extraction
+
+Use the tarfile "data" filter when available, otherwise validate member
+paths and link targets before extracting (CVE-2026-41140).
+
+Adapted to 1.3.2, where sdists are extracted in inspection/info.py.
+
+Origin: backport,
https://github.com/python-poetry/poetry/commit/e512e7fc5557251c7c9c59d0029506e77db1ea18
+Bug:
https://github.com/python-poetry/poetry/security/advisories/GHSA-73h3-mf4w-8647
+---
+diff --git src/poetry/inspection/info.py src/poetry/inspection/info.py
+index 54372b5..bd0bd54 100644
+--- a/src/poetry/inspection/info.py
++++ b/src/poetry/inspection/info.py
+@@ -5,6 +5,7 @@ import functools
+ import glob
+ import logging
+ import os
++import sys
+ import tarfile
+ import zipfile
+
+@@ -60,6 +61,44 @@ with build.env.IsolatedEnvBuilder() as env:
+ PEP517_META_BUILD_DEPS = ["build===0.7.0", "pep517==0.12.0"]
+
+
++
++def _extract_tar_safely(archive: tarfile.TarFile, dest: Path) -> None:
++ # These versions of python shipped with a broken tarfile data_filter, per
++ # https://github.com/python/cpython/issues/107845.
++ broken_tarfile_filter = {(3, 10, 12), (3, 11, 4)}
++ if (
++ hasattr(tarfile, "data_filter")
++ and sys.version_info[:3] not in broken_tarfile_filter
++ ):
++ archive.extractall(dest, filter="data")
++ return
++
++ # Validate all member paths before extraction
++ dest = Path(os.path.abspath(dest))
++ safe_members = []
++ for member in archive.getmembers():
++ member_path = Path(os.path.abspath(dest / member.name))
++ if not member_path.is_relative_to(dest):
++ raise ValueError(
++ f"Refusing to extract {member.name}: would write outside
{dest}"
++ )
++ if member.issym():
++ link_target = Path(os.path.abspath(member_path.parent /
member.linkname))
++ if not link_target.is_relative_to(dest):
++ raise ValueError(
++ f"Refusing symlink {member.name}: "
++ f"target {member.linkname} outside {dest}"
++ )
++ elif member.islnk():
++ link_target = Path(os.path.abspath(dest / member.linkname))
++ if not link_target.is_relative_to(dest):
++ raise ValueError(
++ f"Refusing hardlink {member.name}: "
++ f"target {member.linkname} outside {dest}"
++ )
++ safe_members.append(member)
++ archive.extractall(dest, members=safe_members)
++
+ class PackageInfoError(ValueError):
+ def __init__(self, path: Path | str, *reasons: BaseException | str) ->
None:
+ reasons = (f"Unable to determine package info for path: {path!s}",) +
reasons
+@@ -309,7 +348,10 @@ class PackageInfo:
+ with temporary_directory() as tmp_str:
+ tmp = Path(tmp_str)
+ with context(path.as_posix()) as archive:
+- archive.extractall(tmp.as_posix())
++ if isinstance(archive, zipfile.ZipFile):
++ archive.extractall(tmp.as_posix())
++ else:
++ _extract_tar_safely(archive, tmp)
+
+ # a little bit of guess work to determine the directory we care
about
+ elements = list(tmp.glob("*"))
diff -Nru poetry-1.3.2+dfsg/debian/patches/series
poetry-1.3.2+dfsg/debian/patches/series
--- poetry-1.3.2+dfsg/debian/patches/series 2023-01-12 11:16:44.000000000
+0100
+++ poetry-1.3.2+dfsg/debian/patches/series 2026-11-20 12:00:00.000000000
+0100
@@ -1 +1,2 @@
0001-Accept-Python-version-string-with-a-at-the-end.patch
+CVE-2026-41140-refuse-path-traversal-in-sdist-extraction.patch