Skip to content
Write-up Intermediate

Long Live the Pwn Request: Hacking Microsoft GitHub Repositories and More

Several Microsoft and other GitHub repositories ran workflows on the pull_request_target trigger that checked out and executed code from the pull request head branch, letting an unauthenticated attacker run code in the workflow context. The author used this to steal a GITHUB_TOKEN with write permissions and Azure container registry credentials, and to show that a published GitHub Action could be backdoored by moving a tag.

Adnan Khan Follow

Published on praetorian.com

Software supply chain attacks have been increasing both in frequency and severity in recent months. In response to these attacks, the CISA has even released a cybersecurity information sheet (CSI) on how organizations can secure their CI/CD pipelines.

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

Root cause

Likely the workflow used the pull_request_target trigger, which runs with the base repository's secrets and a write-capable token, and then checked out and executed code from the untrusted pull request branch.

Impact

An unauthenticated attacker could run code in the workflow, steal a write-capable GITHUB_TOKEN and Azure credentials, and potentially backdoor a published action so that downstream users run malicious code, though Microsoft said the Azure credentials were only for CI and not used for production containers.

What the attacker needed

Public repository; workflow on pull_request_target; workflow runs PR branch code; no approval gating

The fix

Microsoft rotated the Azure credentials and rebuilt the repository from a commit before the exploit, and the general mitigation is to avoid running untrusted pull request code under pull_request_target or to gate it behind approval and least-privilege tokens.

How it was found

  1. Fork the target repository.
  2. Modify a build script in the fork to add commands that exfiltrate secrets and the token.
  3. Open a draft pull request from the fork, which triggers the workflow immediately without approval.
  4. Receive the Azure secrets and the base64-encoded token at the attacker-controlled endpoint.
  5. Decode the token and use it to make a benign change, such as creating a branch and tag.
  6. Validate the stolen Azure credentials against the container registries.

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.

GitHub Actions are automated jobs that run when something happens in a repository, such as a new pull request. A special trigger called pull_request_target runs in the context of the main repository, with its secrets and token, but some workflows then download and run the code from the incoming pull request. That means a stranger's code runs with the project's own credentials, so the stranger can read secrets and act as the project.

More by Adnan Khan

View all

4 more disclosed reports, best first.

Similar reports

Same bug class and techniques, clearest first.