Regression tests for the cross-spawn Windows command-injection fix
CVE-2026-137199 changed several Windows parsing assumptions at once. A project that upgrades npm cross-spawn should test the command shapes it actually uses instead of assuming that a clean dependency audit covers every wrapper and batch file.
Vulnerability overview
The flaw affects npm cross-spawn before 6.0.7 and releases 7.0.0 through 7.0.x. It is a CWE-78 command-injection issue with a CVSS 4.0 score of 9.2. The upstream project fixed it in 6.0.7 and 7.1.0.
Mechanism and exploitation conditions
The issue occurs when a Windows batch file forwards arguments with %* and the library does not escape for the second cmd.exe parse. The advisory also documents batch-name normalization with trailing dots or spaces, percent expansion involving an environment variable named with ^, and delayed expansion with !VAR!.
Tests should begin with normal application behavior. Include a .cmd target outside node_modules/.bin, a non-batch executable, a command name ending in a space or dot, arguments containing percent signs and an environment where delayed expansion is enabled. Keep test inputs benign and assert that they remain separate arguments.
Impact
The patch adds quoting, strips trailing characters for batch detection, neutralizes percent expansion, disables delayed expansion and rejects line breaks. A focused test suite can catch a later wrapper that accidentally reintroduces shell interpretation. It also protects against incomplete vendor patches or regressions in application-specific command construction.
Affected products and scope
Run these tests on Windows with the exact Node.js versions used by the application. Linux test runners will not exercise the affected branch. Cover 6.0.7 and 7.1.0, because the two branches have separate release histories. A process that sets options.shell needs a different test contract.
Exposure context
The stored ZoomEye app="Node.js" query returned 5,606,957 matches and the CVE Filter returned 0. That count does not replace repository and CI tests, and it does not prove that any asset reaches the vulnerable code.
Remediation and mitigations
Upgrade to a fixed release, add the tests to the Windows CI lane and run them against the packaged artifact. Test a batch script that uses unquoted %~1; if one exists, treat it as a separate unsafe design because escaping may not be able to protect it. Record the expected child process and exit behavior. Repeat the suite after future dependency or shell-wrapper changes, especially when a build starts using a new global command shim.


