npm cross-spawn 6.0.7
v6.0.7

44 minutes ago

Security

This release fixes two vulnerabilities that affect Windows only:

  • Command injection when spawning batch files (GHSA-ghv9-86vm-4v8m, high). Arguments passed to batch files outside node_modules/.bin, such as npm.cmd or globally installed package shims, could break out of their quotes and run arbitrary commands. %VAR% and !VAR! could also be expanded in some environments.
  • Argument injection via backslashes before a double quote (GHSA-m6qr-m48x-3xhh, medium). Since 6.0.6, arguments with two or more backslashes before a double quote, or at their end, could split into extra arguments or swallow the following ones.

Please upgrade. This is the last release of the 6.x line: future fixes will only be made to 7.x and later.

Thanks to Duong Bui Thai for privately reporting both, to @mohd-akram for reporting the batch file injection in #171, and to @trackoor and @ogffx for independently reporting and fixing the backslash issue in #188 and #190.

Behaviour changes

These only affect Windows, when a command runs through cmd.exe, i.e. batch files and other non-executable commands:

  • Line breaks now throw a TypeError. cmd.exe can't escape them, so arguments with line breaks used to be silently cut short. Both spawn() and spawn.sync() now throw synchronously instead.
  • Inner double quotes are escaped as "" for batch files. Programs called by batch files that don't follow the Microsoft C runtime conventions, such as those written in Go or that use CommandLineToArgvW, may now split arguments containing double quotes differently.
  • cmd.exe runs with /e:on /v:off. This also applies to the batch file itself, e.g. one relying on delayed expansion being enabled in the registry.
  • Batch files that read an argument unquoted with %~1 remain unsafe, as they always were. Please quote it, e.g. "%~1", or forward the arguments with %*.

Please see the new Windows argument escaping section of the README.

Don't miss a new cross-spawn release

NewReleases is sending notifications on new releases.