Keyrook

NewsPatch Notes

Patch alert

cross-spawn flaw lets a crafted argument run commands on Windows

Three flaws in cross-spawn, the helper bundled inside npm and Yarn, let a crafted argument escape its quotes on Windows and run arbitrary commands. The worst scores 8.1; fixed in 7.1.2, 6.0.10 and 8.0.0.

Diagram showing a crafted argument breaking out of its quotes in a Windows batch file and launching the calculator
Diagram: how a crafted argument escapes its quotes and runs a command on Windows

Affects

  • npm
  • Yarn

Tracked as

  • CVE-2026-137197cross-spawn, in npm and Yarn · CVSS 8.1
  • CVE-2026-137198cross-spawn, in npm and Yarn
  • CVE-2026-137199cross-spawn, in npm and Yarn

A small helper that most JavaScript developers never think about has a serious Windows problem. cross-spawn sits inside npm, Yarn and countless build tools, quietly starting other programs for them. Three flaws in how it hands arguments to Windows batch files let a crafted argument slip out of its quotes and run any command the attacker chooses. The advisory landed on 1 December, and the worst of the three flaws scores 8.1.

markdown
```stats
wide: true
caption: "Figures from the advisory and NVD"
items:
  - value: "3"
    label: "Windows flaws"
    note: "All in how arguments reach cmd.exe"
    tone: red
  - value: "8.1"
    label: "Highest score"
    note: "CVE-2026-137197"
    tone: red
  - value: "7.1.2"
    label: "Fixed in 7.x"
    note: "6.0.10 fixes the 6.x line"
    tone: green
  - value: "8.0.0"
    label: "Latest release"
    note: "Also carries the fix"
    tone: green

## The quote that would not hold

On Windows, programs that are not executables — batch files ending in `.bat` or `.cmd` — run through `cmd.exe`, and cross-spawn wraps the command and its arguments in quotes for that shell. The trouble starts when the batch file passes its arguments along, for example with `%*`: the shell reads them a second time, and the second reading can turn a piece of data into a command.

cross-spawn had already hardened that second reading for one case — the small shim scripts npm places in `node_modules/.bin`. For every other batch file it had not. A global shim, `npm.cmd` itself, or any batch file a user keeps on disk was left exposed, and a single crafted argument was enough:

```js
const spawn = require('cross-spawn');

// Runs calc.exe on Windows
spawn.sync('npm', ['" & calc & "']);

The argument opens with a quote, closes it early, and the & characters on either side of calc tell cmd.exe to run it as a separate command. In a real attack the payload would not be the calculator — it could be any command the account running the tool is allowed to run. This is CVE-2026-137199, the flaw at the heart of the advisory, fixed in 6.0.7 and 7.1.0.

The same flaw hid three more tricks. Adding a trailing dot or space to a command name, such as tool.bat , fooled the check that decides whether the target is a batch file at all, because Windows quietly strips those characters. A %VAR% fragment in an argument could be expanded into a value from the environment when a variable named VAR^ existed, and !VAR! could be expanded when delayed expansion was switched on in the registry.

Two more flaws in the same code

The advisory covers two further weaknesses, both fixed in the same releases:

  • CVE-2026-137198 — runs of backslashes before a closing quote, or at the end of an argument, were not doubled. Two or more backslashes could swallow the closing quote, letting attacker-controlled text become extra arguments or swallow the arguments that followed. It does not by itself run a second command, but it can change what the target program does — and the target may accept the altered arguments and exit cleanly, so the caller never notices.
  • CVE-2026-137197 — the highest-scored of the three at 8.1. cross-spawn could miss that cmd.exe would resolve a batch file when the command name carried quotes, delimiters, trailing whitespace, or a child-specific PATHEXT setting. The arguments were then escaped as though the target were an ordinary program, and command metacharacters inside an argument were read by cmd.exe as commands. Fixed in 6.0.8 and 7.1.1.

The fixes escape batch-file arguments with double quotes, in the style Rust adopted after the BatBadBut flaw, neutralise %, run cmd.exe with delayed expansion off, detect batch files after stripping trailing dots and spaces, and reject line breaks outright. Some edge cases cannot be fixed by any escaping — batch files that use %~1 unquoted, for example — and the project’s README documents those limits.

Who is affected

Only Windows is affected, and only applications that pass untrusted input as arguments to a command that runs through cmd.exe. macOS and Linux are untouched, and the deliberately unescaped options.shell mode is unaffected by design.

That still covers a lot of ground. Developers rarely call cross-spawn directly — it arrives inside npm, Yarn, and the build and test tools that wrap them — so a project can carry a vulnerable copy without anyone on the team knowing its name. The check is the lockfile, not memory.

markdown
```callout
tone: yellow
title: "Check the lockfile, not the code"
body: |
  cross-spawn usually arrives as a dependency of a dependency. Search `package-lock.json` or `yarn.lock` for the version in use — a project can be affected even if nobody on the team has ever typed its name.

## What to do

```markdown
```steps
title: "Update and check"
items:
  - title: "Update cross-spawn"
    body: "Move to 7.1.2 on the 7.x line, 6.0.10 on the 6.x line, or 8.0.0. Update npm and Yarn too, since they bundle it."
  - title: "Check lockfiles"
    body: "Run npm audit and search package-lock.json or yarn.lock for older cross-spawn versions hiding in the dependency tree."
  - title: "Tighten how arguments are built"
    body: "Allow only a safe subset of untrusted input, and call executables directly instead of going through batch files."

```markdown
```faq
items:
  - summary: "Does this affect macOS or Linux?"
    body: "No. The flaws are in how arguments are escaped for cmd.exe, which only exists on Windows. Other platforms are not affected."
  - summary: "Can a project be affected without calling cross-spawn directly?"
    body: "Possibly. npm, Yarn and many build tools bundle it, so check the lockfile for the version actually installed rather than relying on what the code imports."
  - summary: "What if an update is not possible right now?"
    body: "Validate untrusted input so only a safe subset is allowed, and call executables directly rather than through batch files, as the advisory suggests."

Sources

  1. Command injection on Windows when spawning batch filesGitHub
  2. cross-spawn v7.1.2 releaseGitHub
  3. BatBadBut: You can't securely execute commands on Windowsflatt.tech

More news

All the news
  1. Patch Notes2 min

    Wren:AM 15.3.1 fixes unauthenticated flaw that can lead to remote code execution

    Wren:AM 15.3.1, released December 2, fixes a deserialization flaw scored 9.8 that lets anyone reach the legacy password-reset pages and run code on the server without logging in.

    • Wren:AM
  2. Patch Notes2 min

    Fastify file uploads can hang on a 67 KB request — update @fastify/busboy to 3.2.7

    A single unauthenticated upload of about 67 KB can stall @fastify/busboy forever, leaving Fastify file uploads hanging. Version 3.2.7, released 2 December 2026, fixes it.

    • @fastify/busboy
  3. Patch Notes2 min

    HPE patches two maximum-severity hard-coded credential flaws in Networking COP

    HPE's December 1 update for Networking Central On-Premises fixes 21 flaws, including two hard-coded credential bugs scored 10.0 that let strangers log in over SSH and take full admin control.

    • HPE Networking Central On-Premises (COP)