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.

