CVE-2019-20916

7.5 HIGH

📋 TL;DR

This vulnerability in pip allows directory traversal attacks when installing packages from URLs. Attackers can overwrite arbitrary files on the system by exploiting the Content-Disposition header parsing. All Python users with pip versions before 19.2 are affected.

💻 Affected Systems

Products:
  • pip (Python package installer)
Versions: All versions before 19.2
Operating Systems: All operating systems where pip is installed
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects pip install commands that use URLs (not PyPI repository installs). Requires user interaction to install from a malicious URL.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise via overwriting critical files like /root/.ssh/authorized_keys, /etc/passwd, or system binaries, leading to remote code execution and persistent access.

🟠

Likely Case

Local privilege escalation or data corruption by overwriting user configuration files, SSH keys, or application data.

🟢

If Mitigated

Limited impact if running pip with minimal privileges, using virtual environments, or restricting package sources to trusted repositories.

🌐 Internet-Facing: MEDIUM - Requires user to run pip install with a malicious URL, which is less common than standard package repository usage.
🏢 Internal Only: MEDIUM - Internal users could exploit this if they can convince administrators to install packages from untrusted URLs.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires the victim to run 'pip install' with a malicious URL. The vulnerability is well-documented with proof-of-concept examples available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 19.2 and later

Vendor Advisory: https://github.com/pypa/pip/security/advisories/GHSA-4w8v-9xjp-5j3r

Restart Required: No

Instructions:

1. Run: pip install --upgrade pip
2. Verify upgrade with: pip --version
3. Ensure version is 19.2 or higher

🔧 Temporary Workarounds

Avoid URL-based installs

all

Only install packages from trusted PyPI repositories, not direct URLs

Use virtual environments

all

Run pip in isolated virtual environments to limit file system access

python -m venv myenv
source myenv/bin/activate

🧯 If You Can't Patch

  • Implement strict policies prohibiting pip install from URLs
  • Run pip with minimal privileges (non-root user) and restrict write permissions

🔍 How to Verify

Check if Vulnerable:

Check pip version: pip --version | grep -E '^(pip|pip3) [0-9]+\.[0-9]+' and compare to 19.2

Check Version:

pip --version

Verify Fix Applied:

After upgrade, verify pip version is 19.2 or higher: pip --version

📡 Detection & Monitoring

Log Indicators:

  • pip install commands with URL arguments
  • Unexpected file modifications in system directories

Network Indicators:

  • HTTP requests to unusual domains during package installation

SIEM Query:

process.name="pip" AND cmdline="*install*http*"

🔗 References

📤 Share & Export