Skip to content
Race condition Advisory Advanced

GHSL-2026-166: TOCTOU in the MongoDB Node.js Driver release notes workflow

The release_notes workflow checked that the person triggering it was a maintainer, but then checked out the mutable pull request head ref rather than the commit that was reviewed. An external pull request author could push a new commit after the trigger and have their code run in a job holding a GITHUB_TOKEN with contents and pull-requests write permissions.

jarlob Follow

Originally disclosed on GitHub Security Lab

The releasenotes workflow authorizes a maintainer to trigger a run, but does not bind that authorization to the commit that the maintainer reviewed. It subsequently checks out the mutable refs/pull/<number>/head ref and executes files from that checkout.

jarlob, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The workflow authorised the triggering actor but never bound that authorisation to a specific commit, then checked out the mutable refs/pull/<number>/head ref and executed files from it.

Impact

Attacker-controlled JavaScript could run on a GitHub Actions runner and use a GITHUB_TOKEN with contents: write and pull-requests: write to alter repository content or pull request state, though a maintainer must trigger the workflow and branch protection may restrict changes to protected refs.

What the attacker needed

An open pull request from an external contributor; a maintainer triggers the workflow; attacker can push to the PR head

The fix

The workflow was fixed so that the authorisation is tied to the specific commit that is checked out and executed.

How it was found

  1. The contributor presents a benign commit for review.
  2. A maintainer dispatches the workflow for that pull request or posts the accepted run release_notes comment.
  3. The contributor updates the pull request head before actions/checkout resolves refs/pull/<number>/head.
  4. The maintainer passes the authorization check, but the workflow checks out and executes the contributor’s new, unauthorised commit.
  5. Modified lifecycle code executes during installation, and modified repository scripts subsequently execute with GITHUB_TOKEN in their environment.

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 report has not been written yet. The Original tab links to the source.

A GitHub Actions workflow is an automated job that runs on GitHub's servers. This one was meant to let a trusted maintainer generate release notes for a pull request, but it fetched whatever the latest commit on that pull request was at the moment it ran, not the version the maintainer had looked at. So an outside contributor could quietly push new code in between the approval and the run, and that code would execute with a token that can write to the repository.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by jarlob

View all

192 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.