CVE-2022-21668 Pipenv's requirements.txt parsing allows malicious index url in comments

High 8.0 Published Updated

Attackers can inject malicious index URLs in requirements.txt comments, causing pipenv to install malicious packages and execute arbitrary code.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2022-21668?

CVE-2022-21668 is a high-severity vulnerability in Fedoraproject Fedora, published on 10 Jan 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

Official description

pipenv is a Python development workflow tool. Starting with version 2018.10.9 and prior to version 2022.1.8, a flaw in pipenv's parsing of requirements files allows an attacker to insert a specially crafted string inside a comment anywhere within a requirements.txt file, which will cause victims who use pipenv to install the requirements file to download dependencies from a package index server controlled by the attacker. By embedding malicious code in packages served from their malicious index server, the attacker can trigger arbitrary remote code execution (RCE) on the victims' systems. If an attacker is able to hide a malicious `--index-url` option in a requirements file that a victim installs with pipenv, the attacker can embed arbitrary malicious code in packages served from their malicious index server that will be executed on the victim's host during installation (remote code execution/RCE). When pip installs from a source distribution, any code in the setup.py is executed by the install process. This issue is patched in version 2022.1.8. The GitHub Security Advisory contains more information about this vulnerability.

Weakness: CWE-190, CWE-1284, CWE-791, CWE-78, CWE-77, CWE-427, CWE-20

Which versions are affected by CVE-2022-21668?

3 open source packages ship an affected version, including pipenv. It affects 2 products.

PackageAffectedFixed in
pipenv PyPIFrom 2018.10.92022.1.8
pipenv PyPIFrom 2018.10.92022.1.8
pipenv PyPIFrom 2018.10.92022.1.8

Products include Fedoraproject Fedora, Pypa Pipenv.

How do I fix CVE-2022-21668?

Upgrade pipenv to 2022.1.8 or later.

Is CVE-2022-21668 being exploited?

There is no known exploitation of CVE-2022-21668 in the wild and no public exploit code.

Public exploit code: 1 proofs of concept on GitHub.

All Fedoraproject Fedora vulnerabilities

Sources

Also known as GHSA-qc9x-gjcv-465w, PYSEC-2022-6, ROOT-APP-PYPI-CVE-2022-21668, UBUNTU-CVE-2022-21668.

Is CVE-2022-21668 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free