CVE-2026-8643: pip can extract console_scripts and gui_scripts outside installation directory
AIONLYREPORT package: python-pip-26.0.1-2.1.hum1 ------ Summary: Path Traversal via Malicious Entry Point Name in Wheel Metadata: A malicious wheel can use traversal or absolute entry-point names so pip writes generated script wrappers outside the intended scheme.scripts directory and overwrites files writable by the installing user. Requirements to exploit: An attacker must induce a victim to install a malicious wheel. The wheel must contain crafted consolescripts or guiscripts names with ../ traversal or absolute-path components in entrypoints.txt. The resulting overwrite is limited by the permissions of the installing user, but pip’s wheel-install flow reaches the vulnerable write path in normal operation and sets maker.clobber = True, so existing writable files are replaced when reachable. Component affected: github.com/pypa/pip - wheel installation flow in src/pip/internal/operations/install/wheel.py, vendored distlib script generation in src/pip/vendor/distlib/scripts.py, and entry-point parsing in src/pip/vendor/distlib/util.py Version affected: 26.0.1 (confirmed). Likely affects versions containing the same getentrypoints(...) -> getconsolescriptspecs(...) -> ScriptMaker.writescript(...) flow without target-directory enforcement. Patch available: no (a minimal proposed fix is included below; upstream release status unknown) Version fixed (if any already): unknown Upstream coordination: Not yet notified. This report is the initial triage. CVSS: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H AV:N - An attacker can distribute a malicious wheel through a package source or other network-delivered artifact. AC:L - Crafting traversal or absolute entry-point names in entrypoints.txt is straightforward. PR:N - The attacker needs no privileges on the victim system. UI:R - The victim must install the malicious wheel. S:U - Impact remains within the installing user's security scope. C:N - The primitive is attacker-controlled file overwrite, not direct data disclosure by default. I:H - Escaping scheme.scripts can overwrite writable files outside the intended install directory. A:H - Overwriting critical writable files can break applications or system behavior. Impact: Likely Important. This is a real arbitrary file overwrite/path traversal flaw in pip’s wheel installation flow. Exploitation requires a victim to install a malicious wheel, and the overwrite is limited to paths writable by the installing user. The written content is constrained to pip’s generated entry-point wrapper format rather than fully arbitrary bytes, which narrows the direct confidentiality impact, but escaping scheme.scripts can still severely affect integrity and availability and can lead to code execution when privileged or security-sensitive targets are overwritten. Embargo: yes Reason: No official fix is available, and the bug turns a malicious wheel into a write primitive outside the intended installation directory during a normal pip install flow. Public disclosure before a fix would make malicious package distribution campaigns easier, especially where wheels are installed with elevated privileges. Suggested public date: 15-Jul-2026 Acknowledgement: Aisle Research Steps to reproduce: 1. From the unpacked source tree, run: bash python - <<'PY' import os, tempfile, sys sys.path.insert(0, 'src') from pip.internal.operations.install.wheel import PipScriptMaker base = tempfile.mkdtemp(prefix='pip-script-test-') scripts = os.path.join(base, 'bin') os.makedirs(scripts, existok=True) absolutetarget = os.path.join(tempfile.gettempdir(), 'pip-owned') maker = PipScriptMaker(None, scripts) maker.clobber = True maker.variants = {''} maker.setmode = False for spec in [f'../../outside = os:path.join', f'{absolutetarget} = os:path.join']: files = maker.make(spec) print(spec, '->', files[0], '=>', os.path.abspath(files[0])) PY 2. Observe that the generated output path resolves outside scripts and that the file is written. 3. In a real installation context, a malicious wheel that places the same crafted names in entrypoints.txt reaches the same write sink during pip install and can overwrite attacker-chosen files writable by the installing user. Mitigation: Do not install untrusted wheels, especially in privileged contexts.
Avoid sudo pip install or other elevated wheel-install workflows until a fix is available.
Reject or inspect wheels whose entrypoints.txt contains path separators, .., or absolute entry-point names.
Vulnerability Details
pip already enforces path-traversal checks for wheel archive members extracted from the .whl, but generated entry-point wrappers are created later from metadata and do not go through that containment check. The vulnerable flow is: getentrypoints(distribution) reads consolescripts and guiscripts names from wheel metadata.
getconsolescriptspecs() formats those names into script specifications without sanitizing the name component.
PipScriptMaker.makemultiple() forwards the names to vendored distlib.
ScriptMaker.writescript() uses os.path.join(self.targetdir, name) and writes the generated wrapper without verifying that the resolved path stays inside targetdir.
Additional stage-5 verification confirmed that this is not limited to a direct PipScriptMaker API call: the full wheel-metadata path is reachable in both supported metadata backends, and absolute entry-point names are accepted in addition to ../ traversal. Relevant CWEs: CWE-22 (Path Traversal)
CWE-73 (External Control of File Name or Path)
Proposed Fix
A minimal defense-in-depth fix is to enforce that each generated script path remains inside targetdir before writing: diff diff --git a/src/pip/vendor/distlib/scripts.py b/src/pip/vendor/distlib/scripts.py @@ for name in names: outname = os.path.join(self.targetdir, name) + targetdir = os.path.abspath(self.targetdir) + outnameabs = os.path.abspath(outname) + if os.path.commonpath([targetdir, outnameabs]) != targetdir: + raise ValueError("Invalid script name %r: path traversal/absolute path" % name) if uselauncher: # pragma: no cover n, e = os.path.splitext(outname) Optionally, reject path separators and absolute paths earlier when parsing or validating entry-point names. ------ This report was generated using AI technology. Always review AI-generated content prior to use
Other sources
pip can extract consolescripts and guiscripts outside installation directory
— Microsoft
pip would treat consolescripts and guiscripts as paths instead of file names without sanitizing the resolved absolute path to the installation directory, leading to entry points being installed outside the installation directory.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 24.2-9 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 20.36.1-5 - Upgrade
Upgrade
github.com/pypa/pipto a version that resolves this vulnerability.Fixed in 26.0.1 - Configuration
During wrapper generation, ensure the script output path resolves inside `target_dir` before writing; reject/inspect `console_scripts` and `gui_scripts` entry-point names that contain path separators, `..`, or absolute-path components so they cannot escape the installation scripts directory.
pip wheel installation flow (ScriptMaker._write_script / distlib scripts) Path traversal and absolute-path enforcement for console_scripts/gui_scripts entry-point names = Reject or validate entry-point names so the resolved output path remains inside the intended scripts directory (target_dir/scheme.scripts) - Configuration
When parsing `entry_points.txt` (console_scripts and gui_scripts), reject or inspect any entry-point names whose name component includes path traversal like `../` or absolute-path components, because these can be used to overwrite files writable by the installing user via the script wrapper writer.
wheel metadata entry_points.txt entry_points.txt console_scripts/gui_scripts names = Reject or inspect names that include `../` traversal or absolute-path components - Compensating control
Do not install untrusted wheels; do not install wheels whose `entry_points.txt` contains path traversal or absolute-path components, and avoid installing attacker-controlled wheels in privileged or security-sensitive contexts.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-8643?
The severity of CVE-2026-8643 is categorized as medium with a CVSS score of 4.1.
What vulnerability does CVE-2026-8643 exploit?
CVE-2026-8643 exploits a path traversal vulnerability in pip that allows entry points to be installed outside the installation directory.
How do I fix CVE-2026-8643?
To fix CVE-2026-8643, update pip to the latest version that addresses this path traversal issue.
What impact does CVE-2026-8643 have on Python pip users?
CVE-2026-8643 can potentially allow unauthorized access to scripts since they may be installed outside the intended directory.
Is CVE-2026-8643 a serious threat to applications?
While CVE-2026-8643 has a medium severity rating, it could pose a risk if exploited in environments that allow execution of malicious scripts.