Insecure functionality In shescape
Description
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 ....
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, "")
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
npm | 1.1.3 |
Aliases
1. 2. 3. 4. 5.
References
1. 2. 3. 4.