ThinkFacility Sign in
  1. Home
  2. Security
  3. npm package (cross-spawn)
Criticalnpm package (cross-spawn)

cross-spawn before 7.1.0 and 6.0.7: command injection on Windows through batch files, update now

Node.js developers on Windows whose code, or whose dependencies, pass untrusted input as arguments to a command that runs through a batch file.

How to fix it

You haveUpdate to
>= 7.0.0, < 7.1.0→7.1.0< 6.0.7→6.0.7

Check your version

Which version your project has
npm ls cross-spawn

Update

In your project
npm update cross-spawn
npm ls cross-spawn
Still old? A dependency pins it
npm explain cross-spawn
Then check what's left
npm audit

If you can't update yet

Validate untrusted input so only a safe subset is allowed, and call executables directly rather than through batch files.

Only Windows is affected. A crafted argument to a batch file such as npm.cmd could break out of its quotes and run any command. Lots of tools depend on cross-spawn, so check your lockfile too. Code that sets options.shell was never escaped and still isn't, and the maintainers say some batch files can't be made safe by any escaping.

If npm ls still shows an old version under another package, update that package, or add an "overrides" entry for this one in package.json.

Sources