Cybersecurity

pull_request_target is now blocked by default in public repos: how to audit your workflows

Since December 2, 2026, GitHub Actions blocks pull_request_target workflows in affected public repositories unless an event policy allows them. Learn why the trigger is risky, how to find exposed workflows and what to change.

The risk: a stranger's code next to your secrets

A workflow triggered by pull_request_target runs in the context of the base repository, even for pull requests from forks, and it can read that repository's secrets. That is the key difference from the regular pull_request event.

The danger appears when the workflow checks out and executes the pull request's own code, for example by fetching head.sha and running npm test. The contributor's test script then runs in an environment with secrets and a privileged token. The example below is exactly that kind of risky workflow.

Texttest-fork.yml
on: pull_request_target
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - run: npm test

Audit your workflows with one script

The script walks the YAML files in .github/workflows, reports those using pull_request_target as REVIEW, and marks as HIGH the ones that also reference the pull request's head.sha, head.ref or github.head_ref. It is a plain text search and does not replace a full security review.

We tested it on the box with three sample files: a labeler workflow that only adds labels came out as REVIEW, the workflow that checks out PR code and runs npm test came out as HIGH, and ci.yml, which uses plain push and pull_request, was not listed.

Bashcheck-prt.sh
#!/usr/bin/env bash
# Lists workflows that use pull_request_target and flags those that check out PR code
dir="${1:-.github/workflows}"
for f in "$dir"/*.yml "$dir"/*.yaml; do
  [ -f "$f" ] || continue
  grep -q 'pull_request_target' "$f" || continue
  if grep -Eq 'github\.event\.pull_request\.head\.(sha|ref)|github\.head_ref' "$f"; then
    echo "HIGH   $f: pull_request_target + checkout of PR code"
  else
    echo "REVIEW $f: pull_request_target (blocked by default in public repos)"
  fi
done

How to fix affected workflows

GitHub recommends starting with Policy insights to find blocked workflow runs. Workflows that do not need secrets should move to a safer event such as pull_request.

If a workflow really needs pull_request_target, create or update an applicable GitHub Actions event policy and scope it to specific workflow files. Allow the event only after confirming the workflow will not execute untrusted pull request code with access to secrets or a privileged token.

Recommended reading

All articles