CVE-2022-21235: Github.com/Masterminds/vcs Command Injection Vulnerability With Mercurial Vulnerability

CRITICAL
Advisory Identifier: GHSA-6635-c626-vj4r
CVSS 9.8
CWE-88 CWE-77
Published
Advisory Summary

CVE-2022-21235 is a CRITICAL (CVSS 9.8) command injection vulnerability with mercurial vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting Github.com/Masterminds/vcs libraries in the Go ecosystem. The issue involves command injection vulnerability with mercurial in vcs. Remediation is available by upgrading affected packages to version 1.13.2.

CVE-2022-21235 at a Glance

CVE Identifier CVE-2022-21235
GHSA Identifier GHSA-6635-c626-vj4r
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
Affected Product Github.com/Masterminds/vcs
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.8

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

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

How to Fix CVE-2022-21235

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

github.com/Masterminds/vcs fixed: 1.13.2
Upgrade github.com/Masterminds/vcs to 1.13.2
Verify Direct and Transitive Dependencies

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

inspect dependencies for github.com/Masterminds/vcs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-21235, inspect your project dependencies for Github.com/Masterminds/vcs:

inspect dependencies for github.com/Masterminds/vcs

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

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), where the product constructs a string for a command to be 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. In Github.com/Masterminds/vcs, 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

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.

CVE-2022-21235 Affected Github.com/Masterminds/vcs Versions

1 component(s)
Fixed Versions:
1.13.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/Masterminds/vcs
Go
< 1.13.2
1.13.2

References

Frequently Asked Questions

What is CVE-2022-21235?
CVE-2022-21235 is a security vulnerability in Github.com/Masterminds/vcs involving Command Injection Vulnerability with Mercurial in VCS under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection').
Which Github.com/Masterminds/vcs versions are affected?
Affected versions include releases prior to 1.13.2 across affected packages: github.com/Masterminds/vcs.
What version fixes CVE-2022-21235?
Upgrading to 1.13.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/Masterminds/vcs affected?
Yes, github.com/Masterminds/vcs is affected in releases prior to 1.13.2. Upgrade your dependency to 1.13.2 or later.
What is the CVSS score of CVE-2022-21235?
CVE-2022-21235 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-21235?
CVE-2022-21235 is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (The product constructs a string for a command to be 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.).
How can I check Go dependencies for CVE-2022-21235?
Run the dependency tree command: 'inspect dependencies for github.com/Masterminds/vcs'. 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-6635-c626-vj4r",
  "modified" : "2024-05-20T21:29:38Z",
  "published" : "2022-04-01T14:05:33Z",
  "aliases" : [ "CVE-2022-21235" ],
  "summary" : "Command Injection Vulnerability with Mercurial in VCS",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/Masterminds/vcs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.13.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/vcs/security/advisories/GHSA-6635-c626-vj4r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21235"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/vcs/pull/105"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/vcs/commit/922a5122330ea8fbe56352a0172ddb6bf019cd22"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Masterminds/vcs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Masterminds/vcs/releases/tag/v1.13.2"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-GOLANG-GITHUBCOMMASTERMINDSVCS-2437078"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77", "CWE-88" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-01T14:05:33Z",
    "nvd_published_at" : "2022-04-01T16:15:00Z"
  }
}