The Nx Nightmare A Supply Chain Breach With Ai In The Loop
A misconfigured GitHub Actions workflow in older branches of the Nx project allowed an attacker to run code with high privileges via a malicious pull request, stealing an npm publishing token. The attacker then published backdoored Nx packages that stole credentials and other sensitive data from developer machines.
Developers relying on a popular open-source build system called Nx woke up to find out that the tool they trusted had been compromised — and they might have unknowingly installed malware onto their own machines.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the use of the `pull_request_target` trigger in GitHub Actions workflows on older branches, which runs with elevated permissions and can execute code from untrusted pull requests.
Impact
The malware stole over 2,300 sensitive secrets and was used to make more than 5,500 private repositories public, affecting 400+ organisations.
What the attacker needed
Access to the Nx GitHub repository; ability to open a pull request; vulnerable workflow on an older branch
How it was found
- The attacker submitted a pull request targeting an older branch that still had the vulnerable workflow.
- The GitHub Actions workflow ran the attacker's code automatically due to the misconfiguration.
- The attacker's code extracted the NPM_TOKEN from the CI environment and sent it to a remote server.
- Using the stolen token, the attacker published backdoored versions of Nx packages to npm.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A supply chain attack is when attackers compromise the tools or libraries that developers use, so that when developers install them, they unknowingly install malware. Here, the Nx build tool was compromised because an automated workflow on GitHub was set up in a way that let an outsider run code. That code stole a password (token) that allowed the attacker to publish malicious versions of Nx, which then stole secrets from developers' computers.