# Nx OS command injection via git revisions and remote refs

Source: https://junglewise.ai/threats/nx-os-command-injection-via-git-revisions-and-remote-refs-0ec6868f  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-05. Updated: 2026-10-06  
License: CC BY 4.0 with a link back

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](https://junglewise.ai/threats/technologies/nx). Vendors: [Nrwl](https://junglewise.ai/threats/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

## Related threats

- [Nx shell injection in Maven and Gradle plugins](https://junglewise.ai/threats/cve-2026-119282-nx-is-a-monorepo-solution-for-typescript-and-polyglot-codebases)
- [Nx @nx/docker shell injection in release pipeline](https://junglewise.ai/threats/cve-2026-104859-nx-is-a-monorepo-solution-for-typescript-and-polyglot-codebases)
- [Nx monorepo daemon and plugin worker socket privilege escalation](https://junglewise.ai/threats/cve-2026-104854-nx-is-a-monorepo-solution-for-typescript-and-polyglot-codebases)
- [Nx path traversal in migrate](https://junglewise.ai/threats/cve-2026-104853-nx-is-a-monorepo-solution-for-typescript-and-polyglot-codebases)
- [Nrwl Nx path traversal in self-hosted remote cache](https://junglewise.ai/threats/cve-2026-71476-nrwl-nx-path-traversal-in-self-hosted-remote-cache)
