Skip to content

Command Injection Vulnerability with Mercurial

Moderate
mattfarina published GHSA-6635-c626-vj4r Mar 30, 2022

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.

Impact

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.

Patches

The issue has been fixed in version 1.13.2.

Workarounds

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.

For more information

If you have any questions or comments about this advisory please file an issue.

Severity

Moderate

CVE ID

CVE-2022-21235

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')

The product constructs a string for a command to executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string. Learn more on MITRE.

Credits