highCVE-2026-71538Sep 17, 2026

CVE-2026-71538: @cyclonedx/cyclonedx-npm Windows Shell Injection via --workspace

Shubham Kandhare
Security Engagement Manager, SecureLayer7

The cyclonedx-npm CLI passes the --workspace argument directly into a Windows shell command without escaping, letting anyone who controls that value run arbitrary OS commands on the host.

Package@cyclonedx/cyclonedx-npm
Ecosystemnpm
Affected< 6.0.0
Fixed in6.0.0

The problem

The @cyclonedx/cyclonedx-npm tool generates CycloneDX SBOMs from npm projects. All versions before 6.0.0 contain a Windows-specific OS command injection flaw.

When npm_execpath is not set to a valid npm CLI path, src/npmRunner.ts falls back to constructing a shell command string and passing it to cmd.exe. The --workspace value is interpolated into that string raw, with no escaping or sanitization. Shell metacharacters in the workspace name are executed by the shell with the privileges of the invoking user.

Proof of concept

A working proof-of-concept for CVE-2026-71538 in @cyclonedx/cyclonedx-npm, with the exact payload below.

bash
npx @cyclonedx/cyclonedx-npm --workspace "foo & calc.exe" .

The root cause is in src/npmRunner.ts. The Windows fallback code path builds a shell command string by concatenating the raw --workspace value into it, then passes the whole string to cmd.exe /c. On Windows, & and && are command separators recognized by cmd.exe, so a crafted workspace name like foo & calc.exe causes the shell to execute calc.exe (or any other command) as a second token.

The fix in PR #1489 removes the shell-string construction entirely. npm is now invoked directly as a child process with arguments passed as an array, so metacharacters in the workspace value are never interpreted by a shell. This matches the standard mitigation for CWE-78: avoid shell interpolation and use argument arrays instead.

The fix

Upgrade to @cyclonedx/cyclonedx-npm version 6.0.0 or later. As a short-term workaround on older versions, set the npm_execpath environment variable to the path of npm-cli.js before invoking the tool; this bypasses the vulnerable Windows fallback path. Do not pass untrusted or user-controlled values to --workspace.

Reported by jkowalleck (Jan Kowalleck, CycloneDX maintainer).

References: [1][2][3][4][5]

Related research