# 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 | 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: 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: ```yaml # 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: ```yaml 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 | Date | Change | |---|---| | 2026-06-18 | `actions/checkout@v7` refuses fork PR head/merge refs (`refs/pull/N/head|merge`, fork repo, or head SHA) under `pull_request_target` and PR-triggered `workflow_run`, unless `allow-unsafe-pr-checkout: true` | | 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 `@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): ```bash 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]]. ## Related - [[Software Supply Chain Security]] - [[GitHub Actions Security]] - [[CI-CD Pipeline Attacks|CI/CD Pipeline Attacks]] - [[tj-actions changed-files Compromise]] - [[Shai-Hulud Worm]] - [[SBOM and Provenance]] - [[Malicious Packages]] ## Sources - [[raw/securitylab.github.com/keeping-your-github-actions-secure-part-1-preventing-pwn-requests-4933|GitHub Security Lab — Preventing Pwn Requests]] - [[raw/wiz.io/the-pwn-request-reckoning-what-still-works-against-github-actions-12396|Wiz — The Pwn Request Reckoning]] - [[raw/thehackernews.com/github-updates-actions-checkout-to-block-common-pwn-request-attack-pat-9752|THN — GitHub Updates actions/checkout to Block Pwn Requests]] - [[raw/socket.dev/github-to-block-pull-request-target-workflows-by-default-starting-dece-13507|Socket — GitHub to Block pull_request_target by Default]] - [[raw/snyk.io/ultralytics-ai-pwn-request-supply-chain-attack-9240|Snyk — Ultralytics AI Pwn Request Supply Chain Attack]] - [[raw/blog.pypi.org/supply-chain-attack-analysis-ultralytics-4045|PyPI — Supply-chain attack analysis: Ultralytics]] - [[raw/wiz.io/ultralytics-ai-library-hacked-via-github-for-cryptomining-9459|Wiz — Ultralytics hacked via GitHub for cryptomining]] - [[raw/wiz.io/m-red-team-asyncapi-supply-chain-compromise-via-github-actions-10369|Wiz — AsyncAPI Supply Chain Compromise via GitHub Actions]] - [[raw/aikido.dev/asyncapi-npm-packages-backdoored-via-github-actions-10412|Aikido — AsyncAPI npm packages backdoored via GitHub Actions]] - [[raw/microsoft.com/unpacking-the-asyncapi-npm-supply-chain-compromise-and-import-time-pay-10451|Microsoft — Unpacking the AsyncAPI npm compromise]] - [[raw/unit42.paloaltonetworks.com/github-actions-supply-chain-attack-coinbase-to-tj-actions-4038|Unit 42 — Coinbase to tj-actions]]