> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# github-actions-pull-request-target-checkout

> A pull_request_target or workflow_run workflow checks out the pull request code with the base repository secrets.

## What it flags

A workflow in `.github/workflows/` triggered by `pull_request_target` or `workflow_run` with an `actions/checkout` step whose `ref` or `repository` input points at the pull request's code: `github.event.pull_request.head.sha`, `head.ref`, `head.repo.full_name`, `head.repo.owner.login`, `head.user.login`, `merge_commit_sha`, `github.head_ref`, a `refs/pull/`, `pull/${{ github.event.number }}/` or literal `pull/123/head` ref, or `github.event.workflow_run.head_sha`, `head_branch` or `head_repository.full_name`, in any letter case, directly, through a YAML alias, or through an `env:` variable set to one of them. A step is reported once even when both inputs point at the pull request. These triggers run with the base repository's secrets and a write token, so any build, install or test script in the checked-out code runs with them too (a "pwn request"). [GitHub Security Lab](https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/)

Not flagged: the same checkout under `pull_request`, and a `pull_request_target` checkout of the base ref or with no `ref`. A job or step `if:` that limits the checkout to same-repository pull requests (`head.repo.full_name == github.repository`, `head.repo.fork == false`) or to runs not started by a pull request (`github.event.workflow_run.event == 'push'`, `github.event_name == 'push'`) makes the finding contextual, unless the condition also contains `||`, negates the guard, or compares it again (`(guard) == false`). A reusable workflow that a privileged workflow calls is checked on its own, without the caller's trigger.

Build untrusted code in a `pull_request` workflow, and if a privileged step must follow, pass its results through an artifact to a separate `workflow_run` job that does not execute them.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "github-actions-pull-request-target-checkout": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.