Nx OS command injection via git revisions and remote refs

Severity: high · Published 2026-10-05

Nx is a build system and monorepo manager used by developers to manage complex codebases. An attacker who controls repository content—such as through a pull request or a fork—can inject arbitrary shell commands into git operations, gaining code execution on any developer or CI runner that runs ordinary Nx commands like `nx affected` or `nx import`. This allows attackers to steal credentials, modify build artifacts, or compromise the entire CI environment without needing any access to the victim's machine.

Technologies: Nrwl Nx. Vendors: Nrwl.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
High severity, published 5 October 2026.
Which products and versions are affected?
Nrwl Nx >=14.0.0, <22.7.8; >=23.0.0, <23.1.1.
Is there a fix for This vulnerability?
Yes: fixed in 22.7.8, 23.1.1. Until then: Until you can upgrade, treat `nx.json` from untrusted sources as executable content, do not run `affected` commands against pull requests you have not reviewed, and do not run `nx import` against repositories you do not trust. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run Nrwl Nx at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Fixed in: 22.7.8, 23.1.1

Until you can upgrade, treat `nx.json` from untrusted sources as executable content, do not run `affected` commands against pull requests you have not reviewed, and do not run `nx import` against repositories you do not trust.

Technical details

Nx constructs git command strings by interpolating untrusted values (git revisions, branch names, and remote refs) into shell commands without proper escaping. Two attack vectors exist: the `affected` command path uses `defaultBase`/`NX_BASE`/`NX_HEAD` from `nx.json` or environment in `git merge-base` and `git diff` operations; the `nx import` path uses remote branch names in `git fetch` and `git checkout`. Although values are wrapped in double quotes, POSIX shell command substitution (`$(...)`) executes within double quotes, allowing arbitrary command execution. The `affected` path is particularly critical since it runs automatically in CI on every pull request.

Affected products

  • Nrwl Nx >=14.0.0, <22.7.8; >=23.0.0, <23.1.1

Timeline

  • 2026-10-05: disclosed

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.