REDHAT-BUG-2460927: Path Traversal
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
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
github.com/pypa/pipto a version that resolves this vulnerability.Fixed in 26.0.1 - Configuration
In ScriptMaker._write_script(...), compute outname_abs = os.path.abspath(outname) and target_dir = os.path.abspath(self.target_dir); before writing, enforce containment: if os.path.commonpath([target_dir, outname_abs]) != target_dir then raise ValueError (e.g., "Invalid script name %r: path") and do not write the wrapper.
pip wheel installation flow (PipScriptMaker / distlib scripts) ScriptMaker._write_script path enforcement (target-directory containment) = Enforce that the resolved output path remains within the target_dir; reject/raise on traversal or absolute entry-point/script names so that os.path.commonpath([target_dir, outname_abs]) == target_dir before writing - Configuration
Before passing console_scripts/gui_scripts names into get_console_script_specs(...)/PipScriptMaker, validate the entry-point name from get_entrypoints(distribution): reject or inspect any console_scripts/gui_scripts entry whose name resolves to a path outside scripts or contains path separators/../ or absolute components.
pip / wheel entry point handling (entry_points.txt) console_scripts / gui_scripts name validation = Reject or inspect entries whose entry_points.txt name contains path separators, '..', or absolute-path components - Compensating control
Do not install untrusted wheels, especially in privileged contexts (avoid any workflow that installs attacker-supplied wheel artifacts such as a malicious wheel).
Event History
Frequently Asked Questions
What is the severity of REDHAT-BUG-2460927?
The severity of REDHAT-BUG-2460927 is classified as high with a score of 7.
What vulnerability does REDHAT-BUG-2460927 describe?
REDHAT-BUG-2460927 describes a path traversal vulnerability in the python-pip package, which can lead to malicious script execution.
How do I fix REDHAT-BUG-2460927?
To fix REDHAT-BUG-2460927, you should update the python-pip package to a secure version that addresses the path traversal vulnerability.
What is the risk associated with REDHAT-BUG-2460927?
The risk associated with REDHAT-BUG-2460927 is a potential unauthorized script execution outside the intended directory.
When was REDHAT-BUG-2460927 published?
REDHAT-BUG-2460927 was published on April 22, 2026.