Vulnerabilities in pkg:npm/@npmcli/git

PACKAGE
Advisory Summary

GHSA-hxwm-x553-x359 is a MODERATE arbitrary command injection due to vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting @npmcli/git libraries in the npm ecosystem. The issue involves arbitrary command injection due to improper command sanitization. Remediation is available by upgrading affected packages to version 2.0.8.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@npmcli/git

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@npmcli/git. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-hxwm-x553-x359 - MODERATE Arbitrary Command Injection due to Improper Command Sanitization

GHSA-hxwm-x553-x359 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-hxwm-x553-x359
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product @npmcli/git
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-hxwm-x553-x359

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

@npmcli/git fixed: 2.0.8
npm install @npmcli/git@2.0.8
Verify Direct and Transitive Dependencies

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

npm ls @npmcli/git

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-hxwm-x553-x359, inspect your project dependencies using npm:

npm ls @npmcli/git

Analyze the terminal output to locate any version of @npmcli/git in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.8), your application is affected.

Note: The npm ls @npmcli/git command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where 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. In @npmcli/git, 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

### Summary There exists a command injection vulnerability in `npmcli/git` versions <2.0.8 which may result in arbitrary shell command execution due to improper argument sanitization when `npmcli/git` is used to execute Git commands based on user controlled input. The impact of this issue is possible Arbitrary Command Injection when `npmcli/git` is run with untrusted (user controlled) Git command arguments. ### Impact Arbitrary Command Injection ### Details `npmcli/git` prior to release `2.0.8` passed user controlled input as arguments to a shell command without properly sanitizing this input. Passing unsanitized input to a shell can lead to arbitrary command injection. For example passing `git+https://github.com/npm/git; echo hello world` would trigger the shell execution of `echo hello world`. This issue was remediated by no longer running `npmcli/git` git commands through an intermediate shell. ### Patches This issue has been patched in release `2.0.8` ### Acknowledgements This report was reported to us by @tyage (Ierae Security) through the [GitHub Bug Bounty Program](https://bounty.github.com).

GHSA-hxwm-x553-x359 Affected @npmcli/git Versions

1 component(s)
Fixed Versions:
2.0.8
Product / Package Ecosystem Affected Versions Fixed Version
@npmcli/git
npm
< 2.0.8
2.0.8

References

Frequently Asked Questions

What is GHSA-hxwm-x553-x359?
GHSA-hxwm-x553-x359 is a security vulnerability in @npmcli/git involving Arbitrary Command Injection due to Improper Command Sanitization under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which @npmcli/git versions are affected?
Affected versions include releases prior to 2.0.8 across affected packages: @npmcli/git.
What version fixes GHSA-hxwm-x553-x359?
Upgrading to 2.0.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @npmcli/git affected?
Yes, @npmcli/git is affected in releases prior to 2.0.8. Upgrade your dependency to 2.0.8 or later.
What CWE is associated with GHSA-hxwm-x553-x359?
GHSA-hxwm-x553-x359 is classified under CWE-78: 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.).
How can I check npm dependencies for GHSA-hxwm-x553-x359?
Run the dependency tree command: 'npm ls @npmcli/git'. 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-hxwm-x553-x359",
  "modified" : "2021-08-02T19:02:32Z",
  "published" : "2021-08-05T17:07:39Z",
  "aliases" : [ ],
  "summary" : "Arbitrary Command Injection due to Improper Command Sanitization",
  "details" : "### Summary\nThere exists a command injection vulnerability in `npmcli/git` versions <2.0.8 which may result in arbitrary shell command execution due to improper argument sanitization when `npmcli/git` is used to execute Git commands based on user controlled input. \n\nThe impact of this issue is possible Arbitrary Command Injection when `npmcli/git` is run with untrusted (user controlled) Git command arguments. \n\n### Impact\n\nArbitrary Command Injection\n\n### Details\n\n`npmcli/git` prior to release `2.0.8` passed user controlled input as arguments to a shell command without properly sanitizing this input. Passing unsanitized input to a shell can lead to arbitrary command injection. For example passing `git+https://github.com/npm/git; echo hello world` would trigger the shell execution of `echo hello world`.  \n\nThis issue was remediated by no longer running `npmcli/git` git commands through an intermediate shell.\n\n### Patches\n\nThis issue has been patched in release `2.0.8`\n\n### Acknowledgements\n\nThis report was reported to us by @tyage (Ierae Security) through the [GitHub Bug Bounty Program](https://bounty.github.com).\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@npmcli/git"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/npm/git/security/advisories/GHSA-hxwm-x553-x359"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/npm/git/pull/29"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-02T19:02:32Z",
    "nvd_published_at" : null
  }
}