Vulnerability · Published Jan 10, 2022 · Assigned by GitHub_M
CVE-2022-21668Pipenv's requirements.txt parsing allows malicious index url in comments
High 8.0
In plain English
A high-severity improper input validation in pipenv from pypa. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 3.9% (higher than 90% of all known vulnerabilities). Ready-made attack tooling exists: public proof-of-concept code. Fixed versions are available - upgrade the affected package.
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.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| PyPI | pipenv | 2022.1.8 | GHSA-qc9x-gjcv-465w |
| PyPI | pipenv | 2022.1.8 | PYSEC-2022-6 |
| Ubuntu:22.04:LTS | pipenv | no fix listed | UBUNTU-CVE-2022-21668 |
| Ubuntu:24.04:LTS | pipenv | no fix listed | UBUNTU-CVE-2022-21668 |
| Ubuntu:25.10 | pipenv | no fix listed | UBUNTU-CVE-2022-21668 |
| Ubuntu:26.04:LTS | pipenv | no fix listed | UBUNTU-CVE-2022-21668 |
| Ubuntu:26.10 | pipenv | no fix listed | UBUNTU-CVE-2022-21668 |
Affected products (as reported)
Weakness: CWE-20, CWE-77, CWE-78, CWE-427, CWE-791 · Vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H
References
- https://github.com/pypa/pipenv/security/advisories/GHSA-qc9x-gjcv-465w x_refsource_CONFIRM
- https://github.com/pypa/pipenv/commit/439782a8ae36c4762c88e43d5f0d8e563371b46f x_refsource_MISC
- https://github.com/pypa/pipenv/releases/tag/v2022.1.8 x_refsource_MISC
- FEDORA-2022-77ce20f03a vendor-advisory, x_refsource_FEDORA
- FEDORA-2022-508e460384 vendor-advisory, x_refsource_FEDORA
- FEDORA-2022-0d007466b3 vendor-advisory, x_refsource_FEDORA