Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
pip install <url> allow directory traversal, leading to arbitrary file write #6413
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
for linux, pip usually requires root privileges, we can write following files to get root shell:
for windows, we can write a batch file to the user startup dir, lead to command execution on next boot:
for malicious header:
pip install malicious url result: