Skip to main content
CVE Vulnerability Database

CVE-2026-1703: pip Path Traversal Vulnerability

CVE-2026-1703 is a path traversal vulnerability in pip that allows malicious wheel archives to extract files outside the installation directory. This article covers the technical details, affected versions, and mitigation.

Published:

CVE-2026-1703 Overview

CVE-2026-1703 is a path traversal vulnerability in pip, the Python package installer, that occurs during the extraction of maliciously crafted wheel archives. When pip installs a wheel package, files may be extracted outside the intended installation directory due to improper path validation. The vulnerability is limited to prefixes of the installation directory, which constrains the attack surface and prevents injection or overwriting of executable files in typical deployment scenarios.

Critical Impact

Malicious wheel packages could write files to unexpected locations within the installation directory prefix, potentially leading to configuration tampering or information disclosure in specific environments.

Affected Products

  • pip (Python Package Installer)
  • Python environments using pip for package installation
  • Systems processing untrusted wheel archives

Discovery Timeline

  • 2026-02-02 - CVE CVE-2026-1703 published to NVD
  • 2026-02-03 - Last updated in NVD database

Technical Details for CVE-2026-1703

Vulnerability Analysis

This directory traversal vulnerability (CWE-22) exists in pip's wheel archive extraction functionality. The root issue lies in how pip validates that extracted files remain within the target installation directory. The vulnerability allows an attacker to craft a malicious wheel archive that, when installed via pip, extracts files to locations outside the intended installation directory but still within the same parent path prefix.

The practical impact is constrained by the limitation that traversal is restricted to prefixes of the installation directory. This means attackers cannot arbitrarily write files to any system location—they can only traverse upward within the directory hierarchy that contains the installation target. In typical Python virtual environment or system-wide pip installations, this significantly limits the attack surface.

Root Cause

The vulnerability stems from the use of os.path.commonprefix() instead of os.path.commonpath() for validating that extracted file paths remain within the installation directory. The commonprefix() function performs a character-by-character comparison and can be fooled by carefully crafted path strings that share a common prefix but don't represent a valid directory containment relationship. In contrast, commonpath() properly handles path semantics and correctly identifies whether one path is contained within another.

Attack Vector

The attack requires network access to deliver a malicious wheel package to a target system. An attacker must convince a user or automated system to install a crafted wheel archive containing specially constructed file paths. The attack requires user interaction (such as running pip install on an untrusted package) and low privileges. Successful exploitation allows limited file writes to prefixes of the installation directory, but does not typically enable code execution or significant integrity violations.

python
     abs_directory = os.path.abspath(directory)
     abs_target = os.path.abspath(target)
 
-    prefix = os.path.commonprefix([abs_directory, abs_target])
+    prefix = os.path.commonpath([abs_directory, abs_target])
     return prefix == abs_directory
 

Source: GitHub Commit

The fix replaces os.path.commonprefix() with os.path.commonpath(), which correctly validates path containment by comparing actual directory paths rather than string prefixes.

Detection Methods for CVE-2026-1703

Indicators of Compromise

  • Unexpected files appearing in parent directories of pip installation locations
  • Wheel installation logs showing unusual file extraction paths
  • Modified configuration files in directories adjacent to Python package installations

Detection Strategies

  • Monitor pip installation operations for path traversal patterns in wheel archive contents
  • Implement file integrity monitoring on Python environment directories and their parent paths
  • Audit installed wheel packages for suspicious file path entries in RECORD files

Monitoring Recommendations

  • Enable verbose logging for pip operations in production environments
  • Configure alerts for file creation events in unexpected locations near Python installation directories
  • Regularly scan wheel package contents before installation in CI/CD pipelines

How to Mitigate CVE-2026-1703

Immediate Actions Required

  • Update pip to the patched version containing commit 8e227a9be4faa9594e05d02ca05a413a2a4e7735
  • Audit recently installed wheel packages from untrusted sources
  • Review file system integrity in Python installation directory parents
  • Avoid installing wheel packages from untrusted or unverified sources

Patch Information

The vulnerability has been addressed through GitHub Pull Request #13777. The fix modifies src/pip/_internal/utils/unpacking.py to use os.path.commonpath() instead of os.path.commonprefix() for proper path containment validation. Organizations should update pip to the latest version that includes this security patch. Additional details are available in the Python Security Announce thread.

Workarounds

  • Only install wheel packages from trusted sources such as PyPI with verified signatures
  • Use isolated virtual environments for installing untrusted packages
  • Implement package hash verification when installing from requirements files using --require-hashes
  • Consider using containerized environments for testing untrusted Python packages
bash
# Verify pip version and upgrade to patched release
pip --version
pip install --upgrade pip

# Install packages with hash verification for supply chain security
pip install --require-hashes -r requirements.txt

# Use virtual environments to isolate potentially risky installations
python -m venv isolated_env
source isolated_env/bin/activate

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.