Skip to content
Write-up Advanced

TensorFlow Supply Chain Compromise via Self-Hosted Runner Attack

TensorFlow's self-hosted GitHub Actions runners could be used by any contributor's fork pull request without approval, and the GITHUB_TOKEN had write permissions. An attacker could run code on the runner, steal tokens and secrets, and upload malicious releases to GitHub and PyPI.

Adnan Khan Follow

Published on praetorian.com

With the recent rise and adoption of artificial intelligence technologies, open-source frameworks such as TensorFlow are prime targets for attackers seeking to conduct software supply chain attacks. Over the last several years, Praetorian engineers have become adept at performing highly complex attacks on GitHub…

Justin Copeland, on praetorian.com

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

Impact

An attacker could upload malicious releases to the official TensorFlow GitHub repository and PyPI, gain remote code execution on a self-hosted runner, and retrieve a GitHub Personal Access Token for the tensorflow-jenkins user.

What the attacker needed

A GitHub account; contributor status on the repository; ability to fork the repository

The fix

TensorFlow fixed the issue by requiring approval for workflows from all fork pull requests, including previous contributors, and by changing GITHUB_TOKEN permissions to read-only for workflows on self-hosted runners.

How it was found

  1. Become a contributor by submitting a trivial pull request, such as a typo fix, and getting it merged.
  2. Fork the repository, remove existing pull_request workflows, and add a new workflow that runs on the self-hosted runner and executes a remote script.
  3. Submit a draft pull request to trigger the workflow and gain a command-and-control callback on the runner.
  4. Force-push the draft pull request back to the main commit to hide the malicious changes.
  5. Wait for a non-fork build to run on the compromised runner and steal the GITHUB_TOKEN from the runner's working directory.
  6. Use the stolen token to upload a malicious release asset to GitHub, and steal PyPI and Jenkins tokens from the runner.

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.

TensorFlow uses GitHub Actions to automatically test and release code. A self-hosted runner is a build machine that TensorFlow runs itself, not GitHub. Because pull requests from outside contributors could run on that machine without approval, an attacker could make the machine run their code and then steal passwords and tokens kept there.

Similar reports

Same bug class and techniques, clearest first.