Pwn request
| Class | Software supply chain |
|---|---|
| Also known as | Untrusted checkout in a privileged workflow |
| CWE | CWE-829: Inclusion of Functionality from Untrusted Control Sphere |
| OWASP Top 10 | A03:2025 |
| Typical severity | Critical |
| Affects | GitHub Actions workflows on pull_request_target, workflow_run or issue_comment that fetch a fork's code and run it |
Anyone with a GitHub account can fork a public repository, change any file in the copy and open a pull request. A pwn request is that pull request reaching a privileged Workflow (GitHub Actions): one that runs on pull_request_target, checks out the fork's code and then builds or tests it. The fork's build scripts run with the base repository's secrets and a token that can write to it, so the author of the pull request can steal the secrets or push to the repository.12
Two triggers for one event
GitHub Actions offers two triggers for pull request activity. pull_request runs the workflow file found in the pull request's merge commit. Since a fork's author controls that commit, GitHub gives such a run a read-only GITHUB_TOKEN, withholds the other secrets and applies fork approval policies.2
pull_request_target was added so a workflow could label a pull request or comment on it, which needs write access.1 It gets the base repository's token and its repository and organization secrets, the trust a push gets. That is safe as long as only trusted code runs: the workflow file, and any actions/checkout step with no ref, come from the base repository's default branch, so by default nothing from the fork executes.2 The trigger relaxes a protective default on purpose, in the way CORS lets a site relax the browser's same-origin policy.1
From checkout to code execution
The flaw appears when the author wants fork pull requests tested with secrets, for example to reach a private package registry, and points the checkout at the pull request head:2
# INSECURE
on: pull_request_target
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: make testFetching the files does not run them. The step after it, make test, reads the Makefile from the fork, and the attacker's commands in it run with the job's token and secrets.2 Any step that hands control to the checked-out files works the same way. A pull request can change a build script, redefine the scripts in package.json, add a test, or add a dependency whose install script runs during npm install.1
A job that references no secret is still exposed. The read and write token sits in the runner's memory, and actions/checkout writes it to disk for later steps unless persist-credentials is set to false.1 The code can also arrive through git fetch, gh pr checkout or an artifact downloaded from the fork's run, and a workflow_run or issue_comment workflow that fetches and runs a fork's code is a pwn request too.2
Checking out the fork is safe when its files stay data: a job that diffs the two trees, searches them with grep, or reformats the code and commits it, without running anything from them.1
SpotBugs, 2024
On 28 November 2024 a SpotBugs maintainer, working around a problem in the CI, gave a workflow in spotbugs/sonar-findbugs their own personal access token. On 6 December an account that was later deleted opened a pull request from a fork that changed the mvnw file that the CI called. A pull_request_target workflow ran it and the token leaked. The token also had access to spotbugs/spotbugs, where the attackers later used it to invite an account of their own.3
From there the attackers reached reviewdog and then tj-actions/changed-files, an action used by more than 23,000 repositories. When researchers caught it on 14 March 2025, every tag of that action had been moved to a commit that dumped the runner's memory, secrets included, into the workflow logs.3 The case is described in Software supply chain compromise.
Designs that avoid it
A workflow that needs neither secrets nor write access should use pull_request. Where a result has to go back to the pull request, the work splits in two. A pull_request workflow builds the untrusted code with a read-only token and uploads its results as an artifact. A second workflow on workflow_run holds the write permission, downloads the artifact and posts the comment.14
on:
workflow_run:
workflows: ["Receive PR"]
types: [completed]
permissions:
actions: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
# steps: download the artifact into runner.temp, check the PR number, post the commentThe artifact came from the fork's run and is untrusted. The Security Lab's example unpacks it into ${{ runner.temp }}, outside the workspace, and rejects a pull request number that is not an integer.1
Limiting the workflow to the labeled event, so it runs only after a maintainer adds a label such as safe to test, is a stopgap. The author can push new commits between the label and the start of the run.1 A workflow that keeps pull_request_target should limit the token to the permissions it uses, pass only the secrets it needs, and, on self-hosted runners, use machines that are cut off from internal systems and not reused between runs.2
Changes on GitHub
Before 8 December 2025, a pull request could name any branch of the repository as its base, and pull_request_target ran the workflow file from that branch. A workflow fixed on the default branch could still be run from an older branch. Since that date the workflow and checkout commit always come from the default branch.5
Version 7 of actions/checkout, released on 18 June 2026, refuses to fetch a fork pull request's head or merge commit in pull_request_target runs and in workflow_run runs started by a pull request. From 20 July 2026 the refusal reached every supported major version except v1. Workflows on a major tag such as @v4 received it; those pinned to a commit SHA or to a minor or patch version did not. The input allow-unsafe-pr-checkout turns it off. A run: step that fetches the code with git or gh, and the issue_comment trigger, are outside the check.6
From 2 December 2026, Actions is scheduled to block pull_request_target in public repositories on GitHub Free, Team and Enterprise Cloud unless an Actions event policy allows it, after brownouts on 9 and 16 November. Private and internal repositories are not affected.7
Finding it
Search .github/workflows for pull_request_target, workflow_run and issue_comment, then for a checkout whose ref or repository names the pull request head. CodeQL's query actions/untrusted-checkout/critical reports this pattern with a security severity of 9.3.4 Until 2 December 2026 the new rule runs in evaluate mode, and GitHub shows which runs it would have blocked.7
Review every file in .github/workflows. List each workflow on pull_request_target, workflow_run or issue_comment. For each, check whether any step checks out, fetches or downloads code from a pull request (ref set to the pull request head or merge ref, repository set to the fork, git fetch, gh pr checkout, or an artifact from another run) and then runs a build, test, install or script from it. Where it does, move the build to a pull_request workflow with permissions: contents: read, and keep only the steps that need write access or secrets in a workflow_run workflow that treats downloaded artifacts as data. Set persist-credentials: false on every checkout. Do not add allow-unsafe-pr-checkout. List each file you changed.
In SecFlash
SecFlash reports a workflow on pull_request_target or workflow_run as SF-SEC-802 on the Security page. A token with more access than the job needs shows as SF-SEC-804, and a credential left in the checkout for a later step as SF-SEC-805.
See also
- Secret exposure in CI/CD workflows
- Script injection in GitHub Actions
- Pinning to commit hashes
- Software supply chain compromise
- Securing a GitHub repository
- Branch protection and rulesets
- Principle of least privilege
- Category: Software supply chain
References
- a b c d e f g h i GitHub Security Lab (updated 17 June 2026). "Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests". GitHub Security Lab.
- a b c d e f g GitHub (2026). "Securely using pull_request_target". GitHub Docs.
- a b Gil, Omer; Hahami, Aviad; Greenholts, Asi; Avital, Yaron (20 March 2025, updated 2 April 2025). "GitHub Actions Supply Chain Attack: A Targeted Attack on Coinbase Expanded to the Widespread tj-actions/changed-files Incident". Palo Alto Networks Unit 42.
- a b GitHub (n.d.). "Checkout of untrusted code in a privileged context" (actions/untrusted-checkout/critical). CodeQL query help.
- back GitHub (7 November 2025). "Actions pull_request_target and environment branch protections changes". GitHub Changelog.
- back GitHub (18 June 2026, editor's note 15 July 2026). "Safer pull_request_target defaults for GitHub Actions checkout". GitHub Changelog.
- a b GitHub (2 November 2026). "pull_request_target blocked by default December 2". GitHub Changelog.
External links
- Keeping your GitHub Actions and workflows secure Part 2: Untrusted input, GitHub Security Lab