GHSA-w2vw-w76x-qr89: Nx: OS command injection via git revisions and remote refs
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.
References
- github.com/advisories/GHSA-w2vw-w76x-qr89
- github.com/nrwl/nx/commit/11ab38573478172109bb5306cb30ca4af246caf0
- github.com/nrwl/nx/commit/4159295a037fdbd8e7f44a33a19d85ab3792415b
- github.com/nrwl/nx/commit/9ce184a04d2098a4797c8b0d6877ee079b751abf
- github.com/nrwl/nx/commit/c12850ce7b364db08e325c13541641d754db7123
- github.com/nrwl/nx/commit/cd9b3c068e17adc9c1722b35b9ca962b98542c20
- github.com/nrwl/nx/commit/cf996496bbad727362d48292b50fafc8c3665847
- github.com/nrwl/nx/pull/36348
- github.com/nrwl/nx/pull/36379
- github.com/nrwl/nx/releases/tag/22.7.8
- github.com/nrwl/nx/releases/tag/23.1.1
- github.com/nrwl/nx/security/advisories/GHSA-w2vw-w76x-qr89
Code Behaviors & Features
Detect and mitigate GHSA-w2vw-w76x-qr89 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →