/

CVE-2026-23949

Severity:

HIGH RISK

(8.6)

Path Traversal / Zip Slip in jaraco.context tarball()

CVE-2026-23949

Analyzed

Vulnerability type

Category:

Path Traversal / Zip Slip

CWE:

CWE-22

Impact:

Arbitrary File Write via Archive Extraction

Severity:

HIGH RISK

(8.6)

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 the jaraco.context.tarball() helper can allow malicious tar archives to write files outside the intended extraction directory.

When crafted paths with ../ sequences are processed, attackers may cause arbitrary filesystem locations to be overwritten, especially in scenarios that automatically unpack untrusted or semi-trusted archives.

Affected context

The vulnerability occurs when applications use jaraco.context.tarball() (versions ≥5.2.0 and <6.1.0) to extract tar or nested tar archives, while assuming the helper will safely keep all files within a target directory.

It is relevant in workflows that automatically unpack archives provided by external sources (e.g., uploads, package imports, CI artifacts) without additional path validation or sandboxing.

Exploit preconditions

  • Attack surface: Archive extraction logic that relies on jaraco.context.tarball() for processing .tar, .tar.gz, or nested tar files.
  • Required access: Ability to supply or influence the tar file contents (e.g., file uploads, repository content, remotely fetched archives).
  • Trigger point: Invocation of jaraco.context.tarball() on a crafted archive containing paths with ../ segments or nested tarballs with traversal paths.
  • Why exploitation is possible: The strip_first_component filter strips only the first path component but does not normalize or reject .. segments, allowing entries like dummy_dir/../../etc/passwd to become ../../etc/passwd and to be written relative to the extraction root.

Why this happens

The bug stems from an incomplete normalization and validation of archive member paths before extraction.

The strip_first_component logic splits a path around the first / and takes the remainder without checking for directory traversal patterns (../) or enforcing that the resulting path stays within the intended destination.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled paths are used in file operations without robust canonicalization and containment checks.

Potential impact

  • Overwriting existing files on the filesystem that are writable by the extraction process
  • Placing attacker-controlled files in sensitive locations (e.g., config directories, application data paths)
  • Tampering with application configuration (such as .env or YAML files) to alter behavior or inject secrets
  • Laying groundwork for further attacks, including code execution, if a written file is later loaded or executed by the application or environment

General mitigation guidance

Mitigation generally focuses on enforcing strict path safety during archive extraction and reducing the trust placed in archive contents.

Recommended defensive patterns include:

  • Normalizing each archive member path (e.g., via realpath-like mechanisms) and ensuring it resolves inside the intended destination directory before extracting.
  • Explicitly rejecting any archive entry that contains .., absolute paths, or other disallowed components.
  • Using extraction routines or helper libraries that are designed to be Zip Slip–safe by default.
  • Running extraction processes with least-privilege OS accounts and restricting write access to only non-sensitive directories.
  • Treating nested archives (e.g., inner tarballs) with the same validation rules as top-level entries and avoiding automatic recursive extraction where it is not essential.

How teams detect issues like this

Detection typically involves a mix of code scanning and behavioral checks:

  • Static analysis: Search for uses of jaraco.context.tarball() and verify that no additional path validation is performed on archive members; flag patterns that manipulate paths but do not normalize or constrain them.
  • Code review: Look for custom extraction helpers that strip path components without checking for traversal (../) or absolute paths; verify that nested archive extraction uses the same safeguards.
  • Policy enforcement: Establish guidelines that any file extraction from untrusted archives must include canonicalization and directory-bound checks; integrate these policies into pull request templates and review checklists.
  • Runtime monitoring: Where feasible, monitor for unexpected write operations outside expected extraction directories during archive handling, which can highlight potential exploitation attempts.

Sources

SourceLink
github.comgithub.com/jaraco/jaraco.context/blob/main/jaraco/context/__init__.py#L74-L91
github.comgithub.com/jaraco/jaraco.context/commit/7b26a42b525735e4085d2e994e13802ea339d5f9
github.comgithub.com/jaraco/jaraco.context/security/advisories/GHSA-58pv-8j8x-9vj2
github.comgithub.com/pypa/setuptools/blob/main/setuptools/_vendor/jaraco/context.py#L55-L76

Frequently asked

questions

It can be, if an attacker can cause the application to download or receive and then extract a crafted tar archive (for example through a file upload endpoint, plugin system, or automated artifact processing). In such setups, the impact effectively becomes remote arbitrary file write within the permissions of the extracting process.

The attacker needs the ability to influence the content of the archive passed to jaraco.context.tarball(). Direct shell access is not required; control over an uploaded or otherwise ingested tar file is typically sufficient.

The safest pattern is to enforce strict path containment during extraction: normalize each member path, reject any path that resolves outside the target directory, and avoid trusting archive directory layouts. Additionally, apply the same rules consistently to nested archives and consider using libraries or utilities that explicitly protect against Zip Slip.

Treat archive contents as untrusted input, define a standard, reviewed extraction utility that all code paths use, and include Zip Slip-style checks in code review and static analysis rules. Combining safe-by-default helpers, least-privilege file permissions, and automated checks greatly reduces the likelihood of reintroducing similar path traversal flaws.

Find out what's already
exploitable in your codebase.