GHSL-2026-167: TOCTOU in the MongoDB JS BSON 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.
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.
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 did not bind 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 privileged runner with a GITHUB_TOKEN holding contents and pull-requests write permissions, though a maintainer must trigger the workflow and branch protection may restrict changes to protected refs.
What the attacker needed
An open pull request on the repository; a maintainer triggers the workflow; attacker can push to the PR head branch
The fix
The workflow was fixed in pull request #929, which should bind the authorisation to the reviewed commit rather than a mutable ref.
How it was found
- The contributor presents a benign commit for review.
- A maintainer dispatches the workflow for that pull request or posts the accepted run release_notes comment.
- The contributor updates the pull request head before actions/checkout resolves refs/pull/<number>/head.
- The maintainer passes the authorization check, but the workflow checks out and executes the contributor’s new, unauthorised commit.
- 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 code was latest on the contributor's branch at the moment the job ran, not the code the maintainer had looked at. A contributor could therefore swap in malicious code at the last second and have it run 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.