The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2022-21668

CVE-2022-21668: Pypa Pipenv RCE Vulnerability

CVE-2022-21668 is a remote code execution vulnerability in Pypa Pipenv caused by flawed parsing of requirements files. Attackers can inject malicious code through crafted comments. This article covers technical details, affected versions, and mitigation strategies.

Published: February 18, 2026

CVE-2022-21668 Overview

CVE-2022-21668 is a critical Input Validation vulnerability in pipenv, a popular Python development workflow tool. The flaw exists in pipenv's parsing of requirements files, allowing an attacker to embed a specially crafted string inside a comment anywhere within a requirements.txt file. When victims use pipenv to install the compromised requirements file, dependencies are downloaded from a package index server controlled by the attacker. By embedding malicious code in packages served from their malicious index server, attackers can trigger arbitrary remote code execution (RCE) on victims' systems.

Critical Impact

Attackers can achieve remote code execution by hiding a malicious --index-url option within a requirements file comment, causing pipenv to download and execute malicious packages during installation.

Affected Products

  • pypa pipenv versions 2018.10.9 to prior to 2022.1.8
  • Fedora 34, 35, and 36 (via packaged pipenv)
  • Any system using vulnerable pipenv versions to install requirements files

Discovery Timeline

  • 2022-01-10 - CVE CVE-2022-21668 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-21668

Vulnerability Analysis

This vulnerability stems from improper input validation in pipenv's requirements file parser. The parser fails to properly sanitize or validate content within comments in requirements.txt files. An attacker can exploit this weakness by inserting a malicious --index-url directive hidden within a comment block. When pipenv processes the requirements file, it incorrectly interprets this hidden directive as a legitimate configuration option.

The attack chain operates as follows: when pip installs packages from a source distribution, any code present in the setup.py file is executed during the installation process. By redirecting package downloads to an attacker-controlled index server, the attacker can serve malicious packages containing arbitrary code in their setup.py files. This code executes with the privileges of the user running the installation, potentially leading to complete system compromise.

Root Cause

The root cause is insufficient validation and sanitization of requirements file content, specifically failing to properly handle or escape pip-style options embedded within comments. The parser does not adequately distinguish between legitimate configuration directives and malicious content hidden within comment sections, classified under CWE-20 (Improper Input Validation) and CWE-190 (Integer Overflow or Wraparound).

Attack Vector

This is a local attack vector requiring user interaction. The attacker must convince a victim to use pipenv to install a maliciously crafted requirements.txt file. Attack scenarios include:

  1. Contributing a poisoned requirements.txt to an open-source project
  2. Sharing a malicious requirements file via documentation or tutorials
  3. Compromising a project repository to inject the malicious directive
  4. Supply chain attacks where the attacker modifies shared requirements files

The security patch introduced a new get_host_and_port function to properly parse and validate URLs, ensuring malicious index URLs embedded in comments cannot hijack the package installation process:

python
def get_host_and_port(url):
    """Get the host, or the host:port pair if port is explicitly included, for the given URL.

    Examples:
    >>> get_host_and_port('example.com')
    'example.com'
    >>> get_host_and_port('example.com:443')
    'example.com:443'
    >>> get_host_and_port('http://example.com')
    'example.com'
    >>> get_host_and_port('https://example.com/')
    'example.com'
    >>> get_host_and_port('https://example.com:8081')
    'example.com:8081'
    >>> get_host_and_port('ssh://example.com')
    'example.com'

    :param url: the URL string to parse
    :return: a string with the host:port pair if the URL includes port number explicitly; otherwise, returns host only
    """
    url = urllib3_util.parse_url(url)
    return '{}:{}'.format(url.host, url.port) if url.port else url.host

Source: GitHub Commit 439782a8

Detection Methods for CVE-2022-21668

Indicators of Compromise

  • Unusual network connections to unknown package index servers during pip/pipenv installations
  • Requirements files containing --index-url, --extra-index-url, or -i flags within comment sections
  • Unexpected execution of setup.py scripts from unfamiliar packages
  • Network traffic to non-standard PyPI mirrors or unknown domain names during dependency installation

Detection Strategies

  • Scan requirements files for embedded pip options (e.g., --index-url, -i, --extra-index-url) appearing anywhere in the file, including comments
  • Implement code review processes that specifically check requirements files for suspicious content
  • Use static analysis tools to detect potentially malicious directives in Python dependency files
  • Monitor DNS queries for unusual package index domains during CI/CD pipeline execution

Monitoring Recommendations

  • Enable network monitoring to detect connections to non-standard package repositories during build processes
  • Implement alerts for any pip installation that uses a non-PyPI index server
  • Log and audit all requirements file changes in version control systems
  • Deploy endpoint detection to monitor for suspicious process execution chains during Python package installations

How to Mitigate CVE-2022-21668

Immediate Actions Required

  • Upgrade pipenv to version 2022.1.8 or later immediately
  • Audit all existing requirements.txt files in your projects for suspicious content within comments
  • Review recent changes to requirements files in version control history
  • Temporarily use pip directly with explicit --index-url https://pypi.org/simple/ until pipenv is upgraded

Patch Information

The vulnerability is patched in pipenv version 2022.1.8. The fix introduces proper URL parsing and validation through the new get_host_and_port function in pipenv/utils.py. Users should upgrade using:

bash
pip install --upgrade pipenv>=2022.1.8

For additional details, refer to the GitHub Security Advisory GHSA-qc9x-gjcv-465w and the official release notes for v2022.1.8. Fedora users should apply the appropriate package updates for their distribution version.

Workarounds

  • Manually inspect all requirements.txt files before running pipenv install, specifically searching for any pip options within comments
  • Use pip install -r requirements.txt --index-url https://pypi.org/simple/ directly to explicitly set a trusted index
  • Implement pre-commit hooks that scan requirements files for embedded options before allowing commits
  • Consider using pip-compile or poetry as alternative dependency management tools until upgrade is complete
bash
# Verify current pipenv version
pipenv --version

# Upgrade pipenv to patched version
pip install --upgrade pipenv>=2022.1.8

# Scan requirements files for suspicious content
grep -E '(--index-url|--extra-index-url|-i\s)' requirements*.txt

# Install with explicit trusted index
pip install -r requirements.txt --index-url https://pypi.org/simple/ --trusted-host pypi.org

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPipenv

  • SeverityHIGH

  • CVSS Score8.6

  • EPSS Probability1.48%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityHigh
  • AvailabilityHigh
  • CWE References
  • CWE-20

  • CWE-190
  • Technical References
  • GitHub Release v2022.1.8

  • GitHub Security Advisory GHSA-qc9x-gjcv-465w

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement
  • Vendor Resources
  • GitHub Commit Update
  • Latest CVEs
  • CVE-2026-40322: SiYuan Knowledge Management RCE Vulnerability

  • CVE-2026-40318: SiYuan Path Traversal Vulnerability

  • CVE-2026-40259: SiYuan Auth Bypass Vulnerability

  • CVE-2026-40255: AdonisJS HTTP Server CSRF Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English