pip install <url> allow directory traversal, leading to arbitrary file write #6413
Labels
auto-locked
Outdated issues that have been locked by automation
C: download
About fetching data from PyPI and other sources
type: bug
A confirmed bug or unintended behavior
type: security
Has potential security implications
Environment
Description
This is a security vulnerability.
when installing a remote package via a specified URL "pip install <url>", A malicious server (or a network MitM if downloading over HTTP) can send a Content-Disposition header with filename which contains "../", and pip did not sanitize the filename, join the Temporary directory and the filename as download path, which can write arbitrary file, potentially leading to command execution.
issue occurs in _download_http_url in src/pip/_internal/download.py
poc:
for linux, pip usually requires root privileges, we can write following files to get root shell:
/root/.ssh/authorized_keys
/etc/crontab
for windows, we can write a batch file to the user startup dir, lead to command execution on next boot:
C:\Users<User>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\
for malicious header:
pip install malicious url result:
similar issue:
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9686
The text was updated successfully, but these errors were encountered: