CVE-2021-21384: Shescape Null Characters Not Escaped Vulnerability
HIGHCVE-2021-21384 is a HIGH (CVSS 6.3) null characters not escaped vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting Shescape libraries in the npm ecosystem. The issue involves null characters not escaped. Remediation is available by upgrading affected packages to version 1.1.3.
CVE-2021-21384 at a Glance
Security Impact
CVSS: 6.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N).
How to Fix CVE-2021-21384
To remediate this vulnerability, upgrade all affected Shescape 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 shescape@1.1.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls shescape
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-21384, inspect your project dependencies using npm:
npm ls shescape
Analyze the terminal output to locate any version of Shescape in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.3), your application is affected.
Note: The npm ls shescape 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-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 Shescape, 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
CVE-2021-21384 Affected Shescape Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
shescape
|
npm |
< 1.1.3
|
1.1.3
|
References
Frequently Asked Questions
What is CVE-2021-21384?
Which Shescape versions are affected?
What version fixes CVE-2021-21384?
Is shescape affected?
What is the CVSS score of CVE-2021-21384?
What CWE is associated with CVE-2021-21384?
How can I check npm dependencies for CVE-2021-21384?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-f2rp-38vg-j3gh",
"modified" : "2021-03-18T23:43:39Z",
"published" : "2021-03-18T23:47:56Z",
"aliases" : [ "CVE-2021-21384" ],
"summary" : "Null characters not escaped",
"details" : "### Impact\n\nAnyone using _Shescape_ to defend against shell injection may still be vulnerable against shell injection if the attacker manages to insert a [null character](https://en.wikipedia.org/wiki/Null_character) into the payload. For example (on Windows):\n\n```javascript\nconst cp = require(\"child_process\");\nconst shescape = require(\"shescape\");\n\nconst nullChar = String.fromCharCode(0);\nconst payload = \"foo\\\" && ls -al ${nullChar} && echo \\\"bar\";\nconsole.log(cp.execSync(`echo ${shescape.quote(payload)}`));\n// foototal 3\n// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 18:44 .\n// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 00:09 ..\n// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 18:42 folder \n// -rw-r--r-- 1 owner XXXXXX 0 Mar 13 18:42 file\n```\n\n### Patches\n\nThe problem has been patched in [v1.1.3](https://github.com/ericcornelissen/shescape/releases/tag/v1.1.3) which you can upgrade to now. No further changes are required.\n\n### Workarounds\n\nAlternatively, null characters can be stripped out manually using e.g. `arg.replace(/\\u{0}/gu, \"\")`",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "shescape"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.1.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/security/advisories/GHSA-f2rp-38vg-j3gh"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21384"
}, {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/commit/07a069a66423809cbedd61d980c11ca44a29ea2b"
}, {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/releases/tag/v1.1.3"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/shescape"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-88" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-03-18T23:43:39Z",
"nvd_published_at" : "2021-03-19T00:15:00Z"
}
}