/

CVE-2026-41140

Severity:

HIGH RISK

(8.7)

Path Traversal in Poetry sdist Extraction (CWE-22)

CVE-2026-41140

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write / Filesystem Compromise

Severity:

HIGH RISK

(8.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in Poetry's sdist extraction logic allows tarball contents to be unpacked without safeguards on certain Python versions.

When a malicious tar archive is processed, files can be written outside the intended directory, potentially overwriting or planting files on the host system.

Affected context

This issue affects environments using Poetry on Python versions that lack tarfile.data_filter (specifically 3.10.0–3.10.12 and 3.11.0–3.11.4) where sdist tarballs are extracted via extractall().

It becomes risky when Poetry is used to process untrusted or third-party source distributions, or when tarball provenance and integrity are not strongly enforced.

In these contexts, attacker-controlled archive paths can escape the target extraction directory and land in sensitive locations on the filesystem.

Exploit preconditions

  • Attack surface: sdist tarball handling within Poetry's dependency management workflow.
  • Required access: Ability to supply or influence the sdist tarball being extracted (e.g., publishing a malicious package or tampering with an archive in transit).
  • Trigger point: Invocation of the vulnerable extractall() helper when resolving or installing packages from source distributions.
  • Why exploitation is possible: On affected Python versions, tarfile.extractall() is used without a safety filter or path normalization check, allowing crafted archive members with ../ or absolute paths to escape the target directory.

Why this happens

The vulnerability stems from using tarfile.extractall() without explicit path traversal protections on Python versions that do not support tarfile.data_filter.

Archive entries are trusted as-is, so filenames containing ../ segments or absolute paths can resolve outside the intended extraction directory and overwrite arbitrary locations.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where missing normalization and validation of file paths during extraction breaks directory confinement guarantees.

Potential impact

  • Malicious archives may write files outside the target extraction directory.
  • Critical application or system files could be overwritten or replaced.
  • Attackers can plant executable scripts or configuration files to influence subsequent builds or deployments.
  • Local privilege escalation may be possible if high-privilege processes use Poetry to extract untrusted tarballs.
  • Supply-chain compromise of development or CI environments that rely on Poetry for dependency resolution.

General mitigation guidance

Mitigation patterns focus on enforcing strict path confinement and reducing trust in archive contents.

Common approaches include:

  • Normalizing and validating member paths before extraction to ensure they remain within a designated root directory.
  • Rejecting archive entries containing .., absolute paths, or other unsafe patterns.
  • Using APIs or wrappers that provide built-in extraction filters and path traversal defenses where available.
  • Running dependency management tools under least-privilege accounts and in isolated build environments to limit damage if extraction is abused.
  • Applying strong provenance controls (signatures, checksums, policy-based allowlists) for source distributions to reduce exposure to malicious tarballs.

How teams detect issues like this

Detection typically combines code-level checks with environment hardening:

  • Static analysis rules targeting direct use of tarfile.extractall() or equivalent archive APIs without path validation.
  • Code review guidelines that flag archive extraction logic lacking normalization of paths and directory confinement checks.
  • Security policies for build and CI pipelines that prohibit processing untrusted archives or enforce integrity verification for sdists.
  • Periodic scanning of build scripts and tooling for unsafe filesystem operations, including unchecked writes outside expected directories.
  • Use of automated review tools to surface archive-handling patterns that resemble CWE-22 path traversal risks.

Sources

SourceLink
github.comgithub.com/python-poetry/poetry/security/advisories/GHSA-73h3-mf4w-8647
access.redhat.comaccess.redhat.com/errata/RHSA-2026:24866
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-41140
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2461604
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-41140.json

Frequently asked

questions

It can be, depending on how Poetry is used. If a system automatically fetches and extracts source distributions from external package repositories, an attacker who can publish or alter those packages may exploit the vulnerability remotely via the package supply chain.

The attacker must be able to provide or influence the sdist tarball that Poetry extracts—typically by publishing a malicious package, compromising a package repository, or tampering with archives in a build pipeline.

The safest pattern is to enforce path confinement during archive extraction: validate and normalize member paths, reject unsafe entries, and rely on extraction APIs that support filters. Combined with running Poetry in a constrained environment, this significantly reduces risk.

Treat all archive contents as untrusted input, require explicit path validation before writing to disk, adopt secure-by-default archive helpers, and embed checks for unsafe extraction patterns into code review and CI pipelines. Additionally, tighten package provenance controls to limit exposure to malicious sdists.

Find out what's already
exploitable in your codebase.