PYSEC-2023-228: Mercurial configuration injectable in repo revision when installing via pip
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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in v23.3
Event History
Frequently Asked Questions
Who is exposed to this issue?
Users of pip versions before 23.3 are affected only when installing a package from a Mercurial VCS URL, such as an hg+ URL. Users who do not install from Mercurial are not affected.
What access does an attacker need to exploit it?
The attacker needs the ability to influence the Mercurial revision specified for a pip installation. That revision can inject Mercurial configuration options into the hg clone invocation, potentially changing how and which repository is installed.
What should be done if the affected installation method is required?
Upgrade pip to version 23.3 or later. Until upgrading is possible, avoid installing packages from Mercurial VCS URLs and do not use untrusted or attacker-influenced Mercurial revision values.