Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLWYycnAtMzh2Zy1qM2do
Null characters not escaped
Impact
Anyone using Shescape to defend against shell injection may still be vulnerable against shell injection if the attacker manages to insert a null character into the payload. For example (on Windows):
const cp = require("child_process");
const shescape = require("shescape");
const nullChar = String.fromCharCode(0);
const payload = "foo\" && ls -al ${nullChar} && echo \"bar";
console.log(cp.execSync(`echo ${shescape.quote(payload)}`));
// foototal 3
// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 18:44 .
// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 00:09 ..
// drwxr-xr-x 1 owner XXXXXX 0 Mar 13 18:42 folder
// -rw-r--r-- 1 owner XXXXXX 0 Mar 13 18:42 file
Patches
The problem has been patched in v1.1.3 which you can upgrade to now. No further changes are required.
Workarounds
Alternatively, null characters can be stripped out manually using e.g. arg.replace(/\u{0}/gu, "")
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLWYycnAtMzh2Zy1qM2do
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: almost 4 years ago
Updated: about 2 years ago
CVSS Score: 6.3
CVSS vector: CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N
EPSS Percentage: 0.00081
EPSS Percentile: 0.36501
Identifiers: GHSA-f2rp-38vg-j3gh, CVE-2021-21384
References:
- https://github.com/ericcornelissen/shescape/security/advisories/GHSA-f2rp-38vg-j3gh
- https://github.com/ericcornelissen/shescape/commit/07a069a66423809cbedd61d980c11ca44a29ea2b
- https://github.com/ericcornelissen/shescape/releases/tag/v1.1.3
- https://nvd.nist.gov/vuln/detail/CVE-2021-21384
- https://www.npmjs.com/package/shescape
- https://github.com/advisories/GHSA-f2rp-38vg-j3gh
Blast Radius: 9.1
Affected Packages
npm:shescape
Dependent packages: 15Dependent repositories: 28
Downloads: 12,137 last month
Affected Version Ranges: < 1.1.3
Fixed in: 1.1.3
All affected versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.1.0, 1.1.1, 1.1.2
All unaffected versions: 1.1.3, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 2.1.1