---
title: "GHSA-w2vw-w76x-qr89: Nx: OS command injection via git revisions and remote refs"
description: "High severity. Nx: OS command injection via git revisions and remote refs. Affects nx; fixed in 23.1.1."
url: https://inlinr.com/advisories/GHSA-w2vw-w76x-qr89
lang: en
---

[Packages](https://inlinr.com/packages) / [nx](https://inlinr.com/packages/nx) / [Security](https://inlinr.com/packages/nx/security)

High Vulnerability GHSA-w2vw-w76x-qr89 Published 5 Oct 2026

# Nx: OS command injection via git revisions and remote refs

Your version 

Affected releases · [nx](https://inlinr.com/packages/nx)

- 23.x 23.0.0 – 23.1.0 Fixed in 23.1.1
- 22.x 22.0.0 – 22.7.7 Fixed in 22.7.8
- 21.x and older 14.0.0 – 21.8.0 No fix, no longer updated

On 23.x, the newest line:

```
npm install nx@23.1.1
```

Every release on a timeline

9999.x 

1. Not affected

9999.0.1  
1 release

23.x 

1. Affected

23.0.0 – 23.1.0  
4 releases
2. Fixed

23.1.1 – 23.3.3  
9 releases

22.x 

1. Affected

22.0.0 – 22.7.7  
46 releases
2. Fixed

22.7.8 – 22.7.12  
5 releases

21.x 

1. Affected

21.0.0 – 21.8.0  
47 releases

20.x 

1. Affected

20.0.0 – 20.12.0  
53 releases

19.x 

1. Affected

19.0.0 – 19.8.15  
65 releases

18.x 

1. Affected

18.0.0 – 18.3.5  
24 releases

17.x 

1. Affected

17.0.0 – 17.3.2  
22 releases

16.x 

1. Affected

16.0.0 – 16.10.0  
35 releases

15.x 

1. Affected

15.0.0 – 15.9.7  
60 releases

14.x 

1. Affected

14.0.0 – 14.8.9  
83 releases

666 stable releases of nx, oldest to newest, one row per major.

## What happens

Summary

Nx core builds several `git` invocations as shell command strings with untrusted values interpolated into them, so a value that should be a git revision or ref is parsed by `/bin/sh` instead. Two entry points are reachable by an attacker: `affected` commands, where `defaultBase` / `affected.defaultBase` from `nx.json` (and the `NX_BASE` / `NX_HEAD` environment variables) reach `git merge-base` and `git diff`; and `nx import`, where a branch name advertised by a remote repository reaches `git fetch`, `git checkout`, and `git config`. In both cases an attacker who controls a repository — or who opens a pull request against one — gets arbitrary command execution on the machine of anyone who runs an ordinary Nx command against it, including CI runners.

The `affected` path is the more serious of the two. `nx affected` and `nx show projects --affected` run constantly in CI, so a pull request that changes nothing but `nx.json` is enough to execute code on the runner with whatever credentials that job holds.

Severity

Exploitable by anyone who controls repository content — a fork's pull request, or a repository the victim clones — that the victim then runs an ordinary `nx affected` or `nx import` against; no access to the victim's machine is required. We have no evidence of exploitation in the wild.

Affected & Patched Versions

| Package | Vulnerable                                 | Patched        |
| ------- | ------------------------------------------ | -------------- |
| nx      | \>= 14.0.0, < 22.7.8; \>= 23.0.0, < 23.1.1 | 22.7.8, 23.1.1 |

Treat every version below the patched ones as affected.

Remediation

Upgrade to **22.7.8** (22.x line) or **23.1.1** (23.x line) or later:

```
nx migrate 23.1.1
```

The fix is a drop-in — no configuration changes are required. If you cannot 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.

Details

`affected` commands

Nx computes the merge base and the changed-file set by building `git merge-base` and `git diff` command lines as strings and running them through a shell. The base and head revisions in those strings come from `nx.json`'s `defaultBase` / `affected.defaultBase` or from the `NX_BASE` / `NX_HEAD` environment variables, and a related code path reads file contents with `git show <revision>:<path>` the same way. Because a shell parses the whole line, a revision value containing shell syntax is executed rather than passed to `git`.

The revisions are wrapped in double quotes, which looks protective but is not: POSIX shells still perform command substitution inside double quotes, so a value of `$(…)` runs without needing to break out of the quotes.

`nx import`

The `GitRepository` helper runs every git operation — `fetch`, `checkout`, `reset`, `config`, and others — by interpolating its arguments into a shell command string. The untrusted argument is a branch name: `nx import` lists the branches a remote advertises, offers them to the user to choose from, and feeds the chosen name back into those commands. A hostile repository controls the names of its own branches, so it controls the command that runs when one is selected.

Credits

- **Arkadiusz Marta** (RE:SOURCE) — Reporter

## How it is exploited

Exploitable with local access, with no account and a user to do something.

- **Confidentiality**: high
- **Integrity**: high
- **Availability**: high

CVSS:4.0/​AV:L/​AC:L/​AT:N/​PR:N/​UI:P/​VC:H/​VI:H/​VA:H/​SC:N/​SI:N/​SA:N

## References

- [Reference](https://github.com/nrwl/nx/security/advisories/GHSA-w2vw-w76x-qr89 "https://github.com/nrwl/nx/security/advisories/GHSA-w2vw-w76x-qr89")  
github.com/nrwl/nx/security/advisories/GHSA-w2v…
- [Pull request](https://github.com/nrwl/nx/pull/36348 "https://github.com/nrwl/nx/pull/36348")  
#36348
- [Pull request](https://github.com/nrwl/nx/pull/36379 "https://github.com/nrwl/nx/pull/36379")  
#36379
- [Fix commit](https://github.com/nrwl/nx/commit/11ab38573478172109bb5306cb30ca4af246caf0 "https://github.com/nrwl/nx/commit/11ab38573478172109bb5306cb30ca4af246caf0")  
11ab385
- [Fix commit](https://github.com/nrwl/nx/commit/4159295a037fdbd8e7f44a33a19d85ab3792415b "https://github.com/nrwl/nx/commit/4159295a037fdbd8e7f44a33a19d85ab3792415b")  
4159295
- [Fix commit](https://github.com/nrwl/nx/commit/9ce184a04d2098a4797c8b0d6877ee079b751abf "https://github.com/nrwl/nx/commit/9ce184a04d2098a4797c8b0d6877ee079b751abf")  
9ce184a
- [Fix commit](https://github.com/nrwl/nx/commit/c12850ce7b364db08e325c13541641d754db7123 "https://github.com/nrwl/nx/commit/c12850ce7b364db08e325c13541641d754db7123")  
c12850c
- [Fix commit](https://github.com/nrwl/nx/commit/cd9b3c068e17adc9c1722b35b9ca962b98542c20 "https://github.com/nrwl/nx/commit/cd9b3c068e17adc9c1722b35b9ca962b98542c20")  
cd9b3c0
- [Fix commit](https://github.com/nrwl/nx/commit/cf996496bbad727362d48292b50fafc8c3665847 "https://github.com/nrwl/nx/commit/cf996496bbad727362d48292b50fafc8c3665847")  
cf99649
- [Package](https://github.com/nrwl/nx "https://github.com/nrwl/nx")  
github.com/nrwl/nx
- [Reference](https://github.com/nrwl/nx/releases/tag/22.7.8 "https://github.com/nrwl/nx/releases/tag/22.7.8")  
github.com/nrwl/nx/releases/tag/22.7.8
- [Reference](https://github.com/nrwl/nx/releases/tag/23.1.1 "https://github.com/nrwl/nx/releases/tag/23.1.1")  
github.com/nrwl/nx/releases/tag/23.1.1

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
