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 asnpm.cmdor 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 7.0.4, 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. cross-spawn@6 users can upgrade to 6.0.7.
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.execan't escape them, so arguments with line breaks used to be silently cut short. Bothspawn()andspawn.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 useCommandLineToArgvW, may now split arguments containing double quotes differently. cmd.exeruns 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
%~1remain 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.
Other changes
- Close the file descriptor when reading a shebang fails (#187). Thanks to @xiehuanyi.