CVE-2023-5752: Pip Command Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-mq26-g339-26xf
CVSS 5.5
CWE-77
Published
Advisory Summary

CVE-2023-5752 is a MODERATE (CVSS 5.5) command injection vulnerability (CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')) affecting Pip libraries in the PyPI ecosystem. The issue involves command injection in pip when used with mercurial. Remediation is available by upgrading affected packages to version 23.3.

CVE-2023-5752 at a Glance

CVE Identifier CVE-2023-5752
GHSA Identifier GHSA-mq26-g339-26xf
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
Affected Product Pip
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2023-5752

To remediate this vulnerability, upgrade all affected Pip dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pip fixed: 23.3
pip install pip>=23.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pip

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2023-5752, inspect your installed packages using pip:

pip show pip

Analyze the terminal output to locate any version of Pip in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 23.3), your application is affected.

Note: The pip show pip command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where the product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. In Pip, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

When installing a package from a Mercurial VCS URL, e.g. `pip install hg+...`, with pip prior to v23.3, the specified Mercurial revision could be used to inject arbitrary configuration options to the `hg clone` call (e.g. `--config`). Controlling the Mercurial configuration can modify how and which repository is installed. This vulnerability does not affect users who aren't installing from Mercurial.

CVE-2023-5752 Affected Pip Versions

1 component(s)
Fixed Versions:
23.3
Product / Package Ecosystem Affected Versions Fixed Version
pip
PyPI
< 23.3
23.3

References

NVD — CVE-2023-5752 NVD
https://nvd.nist.gov/vuln/detail/CVE-2023-5752
Pip Source Repository REPOSITORY
https://github.com/pypa/pip/pull/12306
Security Fix Commit FIX COMMIT
https://github.com/pypa/pip/commit/389cb799d0da9a840749fcd14878928467ed49b4
Pip Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/pip/PYSEC-2023-228.yaml
Pip Source Repository REPOSITORY
https://github.com/pypa/pip
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2025/10/msg00028.html
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/622OZXWG72ISQPLM5Y57YCVIMWHD4C3U
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/65UKKF5LBHEFDCUSPBHUN4IHYX7SRMHH
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FXUVMJM25PUAZRQZBF54OFVKTY3MINPW
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KFC2SPFG5FLCZBYY2K3T5MFW2D22NG6E
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YBSB3SUPQ3VIFYUMHPO3MEQI4BJAXKCZ
Pip Security Information SECURITY
https://mail.python.org/archives/list/security-announce@python.org/thread/F4PL35U6X4VVHZ5ILJU3PWUWN7H7LZXL

Frequently Asked Questions

What is CVE-2023-5752?
CVE-2023-5752 is a security vulnerability in Pip involving Command Injection in pip when used with Mercurial under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Which Pip versions are affected?
Affected versions include releases prior to 23.3 across affected packages: pip.
What version fixes CVE-2023-5752?
Upgrading to 23.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pip affected?
Yes, pip is affected in releases prior to 23.3. Upgrade your dependency to 23.3 or later.
What is the CVSS score of CVE-2023-5752?
CVE-2023-5752 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2023-5752?
CVE-2023-5752 is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') (The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2023-5752?
Run the dependency tree command: 'pip show pip'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mq26-g339-26xf",
  "modified" : "2025-11-03T21:51:36Z",
  "published" : "2023-10-25T18:32:26Z",
  "aliases" : [ "CVE-2023-5752" ],
  "summary" : "Command Injection in pip when used with Mercurial",
  "details" : "When installing a package from a Mercurial VCS URL, e.g. `pip install hg+...`, with pip prior to v23.3, the specified Mercurial revision could be used to inject arbitrary configuration options to the `hg clone` call (e.g. `--config`). Controlling the Mercurial configuration can modify how and which repository is installed. This vulnerability does not affect users who aren't installing from Mercurial.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pip"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "23.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-5752"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/pip/pull/12306"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/pip/commit/389cb799d0da9a840749fcd14878928467ed49b4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pip/PYSEC-2023-228.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pypa/pip"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2025/10/msg00028.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/622OZXWG72ISQPLM5Y57YCVIMWHD4C3U"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/65UKKF5LBHEFDCUSPBHUN4IHYX7SRMHH"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FXUVMJM25PUAZRQZBF54OFVKTY3MINPW"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KFC2SPFG5FLCZBYY2K3T5MFW2D22NG6E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YBSB3SUPQ3VIFYUMHPO3MEQI4BJAXKCZ"
  }, {
    "type" : "WEB",
    "url" : "https://mail.python.org/archives/list/security-announce@python.org/thread/F4PL35U6X4VVHZ5ILJU3PWUWN7H7LZXL"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-30T15:00:34Z",
    "nvd_published_at" : "2023-10-25T18:17:44Z"
  }
}