GitHub's latest Actions changelog says public repositories will block pull_request_target by default, with explicitly configured policy exceptions as the only way to keep it running. If your repo labels, comments on or tests fork pull requests through that trigger, don't wait for a red X to tell you. Plan as if the workflow just stops starting. Here's how I'd find every affected workflow, decide which ones deserve an exception, and move the rest to a safer shape before the cutover.
TL;DR
- The new default acts at the trigger, before any job of yours runs, so your own logging can't catch it. Inventory every
pull_request_targetworkflow across your public repos now. - Sort each one into three buckets: metadata only (labels, comments), builds or runs PR code (split it), or unused (delete it). Only the first bucket is a reasonable exception candidate.
- Splitting into
pull_requestplusworkflow_runkeeps untrusted code away from secrets and a write token, which is the whole reason this trigger is being locked down.
What changed and what is actually available
The announcement is short: GitHub's changelog entry says pull_request_target gets blocked by default on public repositories, subject to explicitly configured policy exceptions. That's the whole verified surface. The changelog is the source of truth for the cutover date and for where the exception setting lives, so read it there instead of trusting a summary (including this one).
Why lock it down at all? Under the hood, pull_request_target runs in the context of the base repository, not the fork. That means the job can see repository secrets and gets a token that can write to your repo. That's fine for labelling a PR. It's a footgun the moment a step checks out and runs the code the PR author wrote, because now a stranger's package.json script runs next to your secrets.
This is the same trust boundary problem I walk through in my production checklist for agentic AI security: the danger is never the trigger alone, it's untrusted input reaching something with authority.
Implementation details and limits
Start with an inventory. You can't fix what you haven't listed, and a workflow that never starts produces none of the job logs you'd normally notice. This script walks every public, unarchived repo in an org and prints each workflow file that mentions the trigger:
#!/usr/bin/env bash
# audit-prt.sh: list workflows that use pull_request_target in an org's public repos
# usage: ./audit-prt.sh my-org > prt-inventory.txt
set -uo pipefail # no -e: repos without a workflows folder return 404 and are skipped
ORG="${1:?usage: audit-prt.sh <org>}"
gh repo list "$ORG" --visibility public --no-archived --limit 1000 \
--json nameWithOwner -q '.[].nameWithOwner' |
while read -r repo; do
paths=$(gh api "repos/$repo/contents/.github/workflows" \
-q '.[] | select(.name | test("\\.ya?ml$")) | .path' 2>/dev/null || true)
for path in $paths; do
body=$(gh api "repos/$repo/contents/$path" \
-H "Accept: application/vnd.github.raw" 2>/dev/null || true)
if grep -q "pull_request_target" <<<"$body"; then
echo "$repo $path"
fi
done
done
Then triage each hit. I'd sort them into three buckets, and I'd be strict about the first one:
| Bucket | What the workflow does | What to do |
|---|---|---|
| Metadata only | Adds labels, posts a welcome comment, never checks out PR code | Candidate for a scoped exception |
| Runs PR code | Checks out the PR head, installs, builds or tests it | Split into pull_request plus workflow_run
|
| Unused | Nobody remembers why it exists | Delete it |
The second bucket is the one to worry about. You can spot it mechanically: the trigger plus a checkout of the PR head. This small Python check flags exactly that pattern so you can run it in CI or locally:
# flag_prt.py: flag workflows that run PR code under pull_request_target
# usage: python3 flag_prt.py .github/workflows/*.yml
import re
import sys
HEAD_REF = re.compile(r"github\.event\.pull_request\.head\.(sha|ref)|refs/pull/")
def check(path: str) -> bool:
text = open(path, encoding="utf-8").read()
if "pull_request_target" not in text:
return False
risky = "actions/checkout" in text and bool(HEAD_REF.search(text))
status = "RUNS PR CODE" if risky else "metadata only?"
print(f"{status:15} {path}")
return risky
if __name__ == "__main__":
flagged = [p for p in sys.argv[1:] if check(p)]
sys.exit(1 if flagged else 0)
It's a heuristic, not a proof. A workflow can pull PR code in other ways (a script that calls git fetch, a reusable workflow), so treat "metadata only?" as a question you answer by reading the file.
Evidence and verification checklist
For the "runs PR code" bucket, the fix that has worked for years is to split the work. The untrusted part runs on pull_request, which for forks gets no secrets and a read only token. The privileged part (posting a comment, uploading a report) runs on workflow_run and never executes PR code, it only reads an artifact.
# .github/workflows/pr-test.yml: untrusted half, no secrets, read only token
name: pr-test
on:
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Run tests and record the result as plain data
run: |
set +e
npm test > test-output.txt 2>&1
echo "$?" > exit-code.txt
echo "${{ github.event.number }}" > pr-number.txt
- uses: actions/upload-artifact@v4
with:
name: results
path: |
exit-code.txt
pr-number.txt
# .github/workflows/pr-report.yml: privileged half, never runs PR code
name: pr-report
on:
workflow_run:
workflows: [pr-test]
types: [completed]
permissions:
pull-requests: write
actions: read
jobs:
report:
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate the artifact as data, never as code
id: data
run: |
PR=$(cat pr-number.txt); CODE=$(cat exit-code.txt)
[[ "$PR" =~ ^[0-9]+$ ]] || { echo "bad PR number"; exit 1; }
[[ "$CODE" =~ ^[0-9]+$ ]] || { echo "bad exit code"; exit 1; }
echo "pr=$PR" >> "$GITHUB_OUTPUT"
echo "code=$CODE" >> "$GITHUB_OUTPUT"
- name: Comment on the PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
if [ "${{ steps.data.outputs.code }}" = "0" ]; then MSG="Tests passed."; else MSG="Tests failed with exit code ${{ steps.data.outputs.code }}."; fi
gh pr comment "${{ steps.data.outputs.pr }}" --body "$MSG"
Treat the artifact as untrusted data: validate it, don't source it, don't eval it, and never pass its contents to a shell unvalidated. One gotcha: for fork PRs the workflow_run payload doesn't hand you the PR number, which is why the untrusted half writes it to a file and the privileged half checks it's an integer before using it. Then verify each migrated repo against a short list:
- [ ] The inventory file lists every public repo you own, with each hit bucketed
- [ ] No remaining
pull_request_targetworkflow checks out the PR head - [ ] Every workflow declares
permissions:explicitly, read only by default - [ ] A test fork PR runs the
pull_requesthalf and theworkflow_runhalf posts its result - [ ] Each exception you request has a named owner and a written reason
Where rollout or governance fails
The tricky part isn't the YAML. It's the workflows nobody owns. A trigger that stops firing is easy to miss, so the first sign is often a contributor asking why their PR never got labelled. Put the inventory in a tracked issue with an owner per repo, and don't let "we'll ask for an exception" become the default answer for the second bucket. An exception there just preserves the risk the default exists to remove.
Agents in CI make this sharper. If you've wired an AI coding agent or a triage bot into PR workflows, it has the same problem in a new costume. Microsoft's guidance on least privilege for AI agents asks for scoped identities, explicit tool permissions and auditable authority for automated agents in CI/CD. And OWASP's LLM01 prompt injection entry warns that untrusted external content can manipulate tools and trigger unauthorized actions. A PR title, a diff or a comment is exactly that kind of content. My take: an agent that reads fork PRs should run in the unprivileged half, and anything it wants to write should go through the privileged half as a narrow, validated request. I go deeper on that pattern in this guide to prompt injection defense for AI agents.
Actionable next steps
- Run
audit-prt.shagainst every org you own and commit the output somewhere your team will see it. - Run
flag_prt.pyon each hit and bucket it. - Split every "runs PR code" workflow into
pull_requestplusworkflow_run. - Request exceptions only for metadata only workflows, each with an owner.
- Open a test PR from a fork and watch both halves run.
FAQ
How does GitHub Actions pull_request_target security work?
The trigger runs in the base repository's context, so the job can read secrets and gets a write capable token even when the PR comes from a fork. It's safe while the job never runs PR code, and risky the moment it checks out and executes it. GitHub is now blocking it by default on public repositories, with explicitly configured exceptions.
When should developers adopt GitHub Actions pull_request_target security?
Now, before the cutover in GitHub's changelog. Inventory your workflows first, then split or delete anything that runs PR code, and keep exceptions for metadata only jobs.
Will a blocked workflow show an error?
Don't count on one. Plan as if it simply never starts, which is why the inventory comes first.
Is workflow_run safe by itself?
Only if it never executes code or scripts from the PR. Treat downloaded artifacts as untrusted input and parse them as data.
Related reading: Next.js security hardening: middleware, Server Actions and CSP patterns and why AI code review leaderboards disagree.
If you want a deeper look at keeping agents and bots inside a safe trust boundary, the two guides linked above go much further than this post.
If you want your CI and agent workflows audited and wired up end to end, that is exactly the kind of agentic AI consulting work I take on.
Drop a comment if your setup looks different. I'm curious what variations people are running in production.




Top comments (0)