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 write GITHUB_TOKEN.

How it works

TriggerContextSecrets / tokenFork approval gate
pull_request (fork)merge commit, fork’s workflow YAMLnone / read-onlyyes (“require approval for external contributors”)
pull_request_targetbase repo default branchsecrets + read/write token + default-branch cacheno, because the workflow YAML is considered trusted
workflow_runbase repo, after another workflowsecrets + writeno
issue_comment, repository_dispatchbase reposecrets + writeno

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:

  1. Explicit checkout of PR head, then build. npm install runs preinstall/postinstall, make runs 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 build

Even 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). @openimbot opened PRs #18018/#18020 whose branch names injected into a pull_request_target workflow (format.yml) in the ultralytics/actions custom action, which had reintroduced a template injection Adnan Khan reported in Aug 2024 (GHSA-7x29-qqmq-v6qc). The script poisoned the setup-python pip 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 targeted manual-netlify-preview.yml (pull_request_target + head checkout), and its MDX evaluated JS from rentry[.]co/elzotebo999 to steal the asyncapi-bot PAT. The attacker pushed to auto-publish branches, and the project’s own OIDC trusted-publishing workflow shipped 5 malicious versions (@asyncapi/specs and 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_target workflow in spotbugs/sonar-findbugs held a maintainer PAT. Leaking it started the chain that led to the tj-actions changed-files Compromise.
  • Other pull_request_target compromises reported by THN/Socket: Nx s1ngularity, PostHog, TanStack and kubernetes-el. See Shai-Hulud Worm.

GitHub’s 2026 platform changes

DateChange
2026-06-18actions/checkout@v7 refuses fork PR head/merge refs (`refs/pull/N/head
2026-06-26Read-only cache tokens for untrusted triggers, which closes Actions-cache poisoning
2026-07-20Backported to v2.8.0, v3.7.0, v4.4.0, v5.1.0 and v6.1.0 (not v1)
2026-09-17Workflow Execution Protections (event policies, actor rules) GA
2026-12-02Default 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 @v4 is protected. Standard pinning advice ends up bypassing the fix.
  • Checkout without actions/checkout: git clone/fetch of the PR repo, gh pr checkout N, gh repo clone, and third-party checkout actions.
  • issue_comment (/deploy, /test) and repository_dispatch aren’t covered. Check the commenter’s real permission (getCollaboratorPermissionLevel, not author_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_request for anything that builds PR code. Split privileged follow-up work into workflow_run and 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_ref inside run:.
  • Set permissions: to the minimum, use persist-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.

Sources