Vulnerabilities in pkg:npm/@npmcli/git
PACKAGEGHSA-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.
pkg:npm/@npmcli/git
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
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.
npm install @npmcli/git@2.0.8
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
GHSA-hxwm-x553-x359 Affected @npmcli/git Versions
1 component(s)| 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?
Which @npmcli/git versions are affected?
What version fixes GHSA-hxwm-x553-x359?
Is @npmcli/git affected?
What CWE is associated with GHSA-hxwm-x553-x359?
How can I check npm dependencies for GHSA-hxwm-x553-x359?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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
}
}