CVE-2018-20225 in PIP
Summary
by MITRE
An issue was discovered in pip (all versions) because it installs the version with the highest version number, even if the user had intended to obtain a private package from a private index. This only affects use of the --extra-index-url option, and exploitation requires that the package does not already exist in the public index (and thus the attacker can put the package there with an arbitrary version number). NOTE: it has been reported that this is intended functionality and the user is responsible for using --extra-index-url securely
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 04/16/2026
This vulnerability exists within the python package management system pip where the package installer automatically selects and installs the version with the highest version number from all available package sources. The issue specifically manifests when users employ the --extra-index-url command line option to specify additional package repositories beyond the default public index. The flaw occurs because pip does not differentiate between public and private package sources during version resolution, potentially allowing malicious actors to exploit this behavior by uploading packages to public repositories with higher version numbers than those available in private repositories. This creates a scenario where an attacker can manipulate the package installation process to install unauthorized or malicious code, even when users intend to obtain packages from private sources.
The technical implementation of this vulnerability stems from pip's version resolution algorithm which prioritizes numerical version identifiers without considering source authenticity or trust boundaries. When a package is requested and exists in multiple repositories, pip evaluates all available versions and selects the highest numerical value regardless of which repository contains it. This behavior becomes exploitable when attackers can upload packages to public repositories where they have no access to private repositories, particularly when the package does not already exist in the public index. The vulnerability requires that the attacker control a public index and can upload packages with version numbers higher than those in private repositories, effectively hijacking the installation process through version number manipulation.
The operational impact of this vulnerability is significant for organizations relying on pip for package management, particularly those using private package repositories to store proprietary or sensitive software components. Attackers can exploit this by creating malicious packages with high version numbers in public repositories such as pypi.org, causing legitimate installations to pull these packages instead of the intended private versions. This represents a supply chain attack vector where the integrity of package installations is compromised through version number manipulation. Organizations may unknowingly install backdoored or compromised packages that appear legitimate but are actually malicious versions with higher version numbers. The vulnerability essentially undermines trust in the package resolution process and can lead to unauthorized code execution or data exfiltration through compromised dependencies.
Security mitigations for this vulnerability should focus on implementing strict package source verification and access controls. Organizations should avoid using --extra-index-url with untrusted sources or implement proper source validation mechanisms. The recommended approach involves configuring pip to only use trusted package sources and implementing package signature verification using tools like pip-check or package integrity checking mechanisms. Security teams should also consider using virtual environments with restricted package sources and implementing continuous monitoring for unauthorized package installations. Additionally, organizations should establish clear policies regarding package management and source verification, ensuring that developers understand the risks associated with using additional package repositories. This vulnerability aligns with CWE-478 which addresses missing default case in switch statements, and relates to ATT&CK technique T1195.002 for supply chain compromise through package repositories, highlighting the need for comprehensive package integrity verification and source authentication mechanisms.