Arbitrary Argument InjectionAffected versions of this package are vulnerable to Arbitrary Argument Injection via incorrect backslash doubling in the argument-escaping logic in lib/util/escape.js when spawning commands routed through cmd.exe on Windows. Two or more backslashes preceding a double quote, or appearing at the end of an argument, are not correctly doubled, allowing the argument's closing quote to be escaped. This lets attacker-controlled text split into extra arguments or consume following arguments, enabling an attacker who controls argument values to alter the target program's behavior, for example injecting flags such as --write into a command invoked with --check.
Note: This is only exploitable on Windows when untrusted input is passed as arguments to a command routed through cmd.exe, including npm cmd-shims in node_modules/.bin.
How to fix Arbitrary Argument Injection? A fix was pushed into the master branch but not yet published.
| |
Command InjectionAffected versions of this package are vulnerable to Command Injection via insufficient escaping in lib/util/escape.js when spawning batch files on Windows. When a batch file outside node_modules/.bin forwards its arguments (e.g. with %*), cmd.exe parses them a second time, and an attacker-controlled argument can break out of its quotes to execute arbitrary commands through npm.cmd, globally installed package shims, or user batch files. Additionally, batch file detection can be bypassed with trailing dots or spaces in the command name, %VAR% in an argument can be expanded if an environment variable named VAR^ exists, and !VAR! can be expanded when delayed expansion is enabled in the registry.
Note: This is only exploitable on Windows when untrusted input is passed as arguments to a command that runs through cmd.exe; other platforms and options.shell mode are not affected.
How to fix Command Injection? A fix was pushed into the master branch but not yet published.
| |
Command InjectionAffected versions of this package are vulnerable to Command Injection via the batch-file detection logic in lib/parse.js on Windows, when a command passed to spawn or spawnSync is not written as a plain program name or path. Commands containing double quotes, command-name delimiters (space, tab, ,, ;, =), trailing whitespace, or a child-specific PATHEXT can cause cross-spawn to miss that cmd.exe will resolve the target to a batch file. The arguments are then escaped as though the target were a regular executable rather than a batch file, so command metacharacters in an untrusted argument (for example "&calc) are interpreted by cmd.exe and execute arbitrary commands.
Note: This is only exploitable when the application passes a command in one of the affected forms (quoted, containing delimiters, with trailing whitespace, or with a custom PATHEXT) and passes untrusted input as arguments on Windows.
How to fix Command Injection? A fix was pushed into the master branch but not yet published.
| |