Lucene search

K
nodejsAnonymousNODEJS:1655
HistoryMar 18, 2021 - 11:52 p.m.

Command Injection

2021-03-1823:52:36
Anonymous
www.npmjs.com
39
shell injection
vulnerability
null character
node.js
security patch

EPSS

0.001

Percentile

34.7%

Overview

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

Workarounds

Alternatively, null characters can be stripped out manually using e.g. arg.replace(/\u{0}/gu, "")

Recommendation

The problem has been patched in v1.1.3 which you can upgrade to now. No further changes are required.

References

EPSS

0.001

Percentile

34.7%