Skip to content

Command Injection Vulnerability with Mercurial in VCS

Critical severity GitHub Reviewed Published Mar 30, 2022 in Masterminds/vcs • Updated May 20, 2024

Package

gomod github.com/Masterminds/vcs (Go)

Affected versions

< 1.13.2

Patched versions

1.13.2

Description

URLs and local file paths passed to the Mercurial (hg) APIs that are specially crafted can contain commands which are executed by Mercurial if it is installed on the host operating system. The vcs package uses the underly version control system, in this case hg, to implement the needed functionality. When hg is executed, argument strings are passed to hg in a way that additional flags can be set. The additional flags can be used to perform a command injection. Other version control systems with an implemented interface may also be vulnerable. The issue has been fixed in version 1.13.2. A work around is to sanitize data passed to the vcs package APIs to ensure it does not contain commands or unexpected data. This is important for user input data that is passed directly to the package APIs.

References

@mattfarina mattfarina published to Masterminds/vcs Mar 30, 2022
Published to the GitHub Advisory Database Apr 1, 2022
Reviewed Apr 1, 2022
Published by the National Vulnerability Database Apr 1, 2022
Last updated May 20, 2024

Severity

Critical
9.8
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

CVE ID

CVE-2022-21235

GHSA ID

GHSA-6635-c626-vj4r

Source code

Credits

Checking history
See something to contribute? Suggest improvements for this vulnerability.