PYSEC-2020-173: High severity pypi/pip vulnerability
The pip package before 19.2 for Python allows Directory Traversal when a URL is given in an install command, because a Content-Disposition header can have ../ in a filename, as demonstrated by overwriting the /root/.ssh/authorizedkeys file. This occurs in downloadhttpurl in internal/download.py.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pipto a version that resolves this vulnerability.Fixed in 19.2
Event History
Frequently Asked Questions
What conditions are required to exploit this issue?
An attacker needs to cause pip to install from a URL that returns a Content-Disposition header containing a filename with directory-traversal sequences such as ../. No authentication or user interaction is required according to the supplied CVSS vector.
Which systems are exposed?
Systems using pip versions before 19.2 are affected when pip is used to install a package from a URL. The impact depends on the permissions of the account running pip; the example shows that a root-run installation could overwrite /root/.ssh/authorized_keys.
What should be done if an immediate upgrade is not possible?
Avoid using affected pip versions to install packages directly from URLs, particularly URLs not fully controlled by the organization. Do not run such installations as root, since file overwrites occur with the privileges of the pip process.