Skip to content
Write-up Advanced

First Week, First Hack: Compromising a Package with 40 Million Weekly Downloads

A GitHub Actions workflow in the @img/colour repository used the pull_request_target event, checked out the untrusted pull request head, and ran npm install and npm test, so code from a fork could execute with a write-capable token. The author tricked Dependabot into force-pushing to a branch that fed an upstream pull request, which made the workflow run and dumped the runner's memory, exposing the GITHUB_TOKEN and repository secrets.

GARANCE DE LA BROSSE Follow

Published on depi.security

Hello dear readers, nice to meet you all! Let me introduce myself: my name is Garance, and I started working at Lupin and Holmes two weeks ago in the Offensive Security Research team.

GARANCE DE LA BROSSE, on depi.security

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

The workflow combined the privileged pull_request_target event with a checkout of the untrusted pull request head and execution of npm scripts from that code, so attacker-controlled files ran with a write-capable token.

Impact

The author obtained a token with write access to a package downloaded over 40 million times a week, which could have allowed backdooring the global software supply chain.

What the attacker needed

A fork of the target repository; Dependabot enabled on the fork; ability to open a pull request upstream; a @dependabot recreate comment

The fix

The maintainer replaced pull_request_target with pull_request so the workflow runs without secrets, and the text also suggests restricting runs to non-fork pull requests and applying least privilege.

How it was found

  1. Fork the repository and enable Dependabot on the fork.
  2. Host a script that dumps the runner process memory and secrets to the logs.
  3. Modify package.json on the fork's main branch to add an outdated dependency and a malicious test script.
  4. Wait for Dependabot to open a pull request from its update branch on the fork.
  5. Open a pull request from that Dependabot branch to the upstream main branch.
  6. Comment @dependabot recreate so the bot force-pushes, which triggers the upstream workflow and leaks the token.

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 project on GitHub can run automatic jobs when someone opens a pull request, a proposed code change. This job ran the proposed code with powerful permissions, so the author arranged for a trusted bot to push the malicious change and the job then leaked the job's access token into its public logs. With that token, someone could write to the project's main code.

Similar reports

Same bug class and techniques, clearest first.