Pwn Requests
A privileged GitHub Actions trigger (
pull_request_target,workflow_run,issue_comment, …) processes attacker-controlled fork PR content, such as checked-out code, branch names, titles or artifacts, so a stranger’s PR runs with the base repo’s secrets and a writeGITHUB_TOKEN.
How it works
| Trigger | Context | Secrets / token | Fork approval gate |
|---|---|---|---|
pull_request (fork) | merge commit, fork’s workflow YAML | none / read-only | yes (“require approval for external contributors”) |
pull_request_target | base repo default branch | secrets + read/write token + default-branch cache | no, because the workflow YAML is considered trusted |
workflow_run | base repo, after another workflow | secrets + write | no |
issue_comment, repository_dispatch | base repo | secrets + write | no |
pull_request_target was meant for labeling and commenting. It becomes exploitable when the job pulls PR content into a position where it influences execution. That gives you three variants:
- Explicit checkout of PR head, then build.
npm installrunspreinstall/postinstall,makeruns the Makefile, test runners run tests, and all of these are attacker-controlled:
# INSECURE
on: pull_request_target
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm install && npm buildEven with no secrets.* referenced, the write GITHUB_TOKEN is on disk because actions/checkout defaults to persist-credentials: true.
2. Script injection, no checkout needed. ${{ }} is substituted into the script before bash parses it:
on: pull_request_target
jobs:
greet:
runs-on: ubuntu-latest
steps:
- run: echo "Thanks for PR: ${{ github.event.pull_request.title }}"
# title: "; touch /tmp/pwned; echo INJECTED #Branch names can’t contain spaces, so payloads in github.head_ref use $(...) + ${IFS} (Ultralytics).
3. Artifact / cache poisoning. An unprivileged pull_request job uploads an attacker-built artifact, and a privileged workflow_run job downloads and executes it. Alternatively, a PR job writes to the default-branch Actions cache, which a release job later restores.
Label gates (if: contains(labels, 'safe to test')) are TOCTOU: the attacker can push after the label is applied. Open PRs keep using the vulnerable workflow version that was current when they were opened.
Notable cases
- Ultralytics (Dec 2024, PyPI 8.3.41/8.3.42/8.3.45/8.3.46).
@openimbotopened PRs #18018/#18020 whose branch names injected into apull_request_targetworkflow (format.yml) in theultralytics/actionscustom action, which had reintroduced a template injection Adnan Khan reported in Aug 2024 (GHSA-7x29-qqmq-v6qc). The script poisoned thesetup-pythonpip cache so the legitimate release workflow built an XMRig miner into the wheels. Sigstore and Trusted Publishing attestations showed that 8.3.41/42 came from the real workflow. 8.3.45/46 were missing attestations, which exposed a leftover unrevoked PyPI API token. - AsyncAPI (2026-07-14). 37 PRs, mostly fake-charity noise, hit
asyncapi/generator. PR #2155 targetedmanual-netlify-preview.yml(pull_request_target+ head checkout), and its MDX evaluated JS fromrentry[.]co/elzotebo999to steal theasyncapi-botPAT. The attacker pushed to auto-publish branches, and the project’s own OIDC trusted-publishing workflow shipped 5 malicious versions (@asyncapi/specsand others, about 3M weekly downloads) with valid provenance. The payload was a “M-RED-TEAM v6.4”/Miasma import-time loader. A PoC (Apr 29) and a fix PR (May 17) had sat unmerged for 58 days. - SpotBugs → reviewdog → tj-actions (Dec 2024 to Mar 2025). A
pull_request_targetworkflow inspotbugs/sonar-findbugsheld a maintainer PAT. Leaking it started the chain that led to the tj-actions changed-files Compromise. - Other
pull_request_targetcompromises reported by THN/Socket: Nxs1ngularity, PostHog, TanStack andkubernetes-el. See Shai-Hulud Worm.
GitHub’s 2026 platform changes
| Date | Change |
|---|---|
| 2026-06-18 | actions/checkout@v7 refuses fork PR head/merge refs (`refs/pull/N/head |
| 2026-06-26 | Read-only cache tokens for untrusted triggers, which closes Actions-cache poisoning |
| 2026-07-20 | Backported to v2.8.0, v3.7.0, v4.4.0, v5.1.0 and v6.1.0 (not v1) |
| 2026-09-17 | Workflow Execution Protections (event policies, actor rules) GA |
| 2026-12-02 | Default event policy blocks pull_request_target in public repos unless explicitly allowed. Private and internal repos are not affected |
What still works (Wiz, 2026)
- SHA pins to pre-backport checkout. For example,
@08eba0b…(v4.3.0) is unprotected while@v4is protected. Standard pinning advice ends up bypassing the fix. - Checkout without
actions/checkout:git clone/fetchof the PR repo,gh pr checkout N,gh repo clone, and third-party checkout actions. issue_comment(/deploy,/test) andrepository_dispatcharen’t covered. Check the commenter’s real permission (getCollaboratorPermissionLevel, notauthor_association), pin the head SHA at approval, and abort if the PR changed afterward.- Script injection, artifact poisoning via
download-artifact, persistent state on non-ephemeral self-hosted runners (~/.npm,~/.cache/pip),allow-unsafe-pr-checkout, and private repos.
Audit grep (Wiz):
grep -rnE 'pull_request_target|workflow_run|issue_comment|repository_dispatch|allow-unsafe-pr-checkout|self-hosted|download-artifact|gh (pr checkout|repo clone)|git (clone|fetch)|refs/pull|actions/checkout@v(1|2\.[0-7]|3\.[0-6]|4\.[0-3]|5\.0|6\.0)([^0-9]|$)|\$\{\{[[:space:]]*github\.(event\.|head_ref)' .github/workflows/Defenses
- Use
pull_requestfor anything that builds PR code. Split privileged follow-up work intoworkflow_runand treat its artifacts as untrusted data. Never execute them. - Pass event data through
env:and quote it ("$PR_TITLE"). Never use${{ github.event.* }}/github.head_refinsiderun:. - Set
permissions:to the minimum, usepersist-credentials: false, and put publish secrets in Environments with required reviewers. Don’t store PATs or registry tokens where untrusted triggers run. Use Trusted Publishing and revoke the leftover tokens. - Static analysis: zizmor, CodeQL for Actions. See GitHub Actions Security.
Related
- Software Supply Chain Security
- GitHub Actions Security
- CI/CD Pipeline Attacks
- tj-actions changed-files Compromise
- Shai-Hulud Worm
- SBOM and Provenance
- Malicious Packages
Sources
- GitHub Security Lab — Preventing Pwn Requests · original
- Wiz — The Pwn Request Reckoning · original
- THN — GitHub Updates actions/checkout to Block Pwn Requests · original
- Socket — GitHub to Block pull_request_target by Default · original
- Snyk — Ultralytics AI Pwn Request Supply Chain Attack · original
- PyPI — Supply-chain attack analysis: Ultralytics · original
- Wiz — Ultralytics hacked via GitHub for cryptomining · original
- Wiz — AsyncAPI Supply Chain Compromise via GitHub Actions · original
- Aikido — AsyncAPI npm packages backdoored via GitHub Actions · original
- Microsoft — Unpacking the AsyncAPI npm compromise · original
- Unit 42 — Coinbase to tj-actions · original