CVE-2023-5752 Mercurial configuration injectable in repo revision when installing via pip

Medium 5.5 Published Updated

Attackers can inject arbitrary Mercurial configuration options during pip installation from VCS URLs, potentially leading to code execution.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2023-5752?

CVE-2023-5752 is a medium-severity command injection vulnerability in pip, published on 24 Oct 2023. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

When installing a package from a Mercurial VCS URL (ie "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 (ie "--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.

Weakness: CWE-77

Which versions are affected by CVE-2023-5752?

3 open source packages ship an affected version, including pip. It affects 1 product.

PackageAffectedFixed in
pip PyPIAll versions23.3
pip PyPIAll versions23.3
pip PyPIAll versions23.3
Linux distribution packages (10)
python-pip SUSE:Linux Enterprise Module for Python 3 15 SP4All versions22.3.1-150400.17.12.1
python-pip SUSE:Linux Enterprise Module for Python 3 15 SP5All versions22.3.1-150400.17.12.1
python312-pip SUSE:Linux Enterprise Module for Python 3 15 SP6All versions23.2.1-150600.3.3.1
python-pip SUSE:Linux Enterprise Server 12 SP5All versions10.0.1-13.14.1
python36-pip SUSE:Linux Enterprise Server 12 SP5All versions20.2.4-8.15.1
python-pip SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions10.0.1-13.14.1
python36-pip SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions20.2.4-8.15.1
python-pip openSUSE:Leap 15.4All versions22.3.1-150400.17.12.1
python-pip openSUSE:Leap 15.5All versions22.3.1-150400.17.12.1
python312-pip openSUSE:Leap 15.6All versions23.2.1-150600.3.3.1

Products include Pypa Pip.

How do I fix CVE-2023-5752?

Upgrade pip to 23.3 or later.

Upgrade, and pass arguments to programs as a list instead of through a shell. More about Command injection.

Is CVE-2023-5752 being exploited?

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

Sources

Also known as AZL-39958, AZL-60006, DEBIAN-CVE-2023-5752, ECHO-1342-c991-4c68, GHSA-mq26-g339-26xf, MGASA-2025-0055 and 8 more.

Is CVE-2023-5752 in your software?

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

Check your SBOMs for free