Some plants look very innocent until a fly brushes the little hairs inside and the leaf snaps shut. GitHub Actions triggers have a bit of that: a ten-line YAML file that looks like it just runs the tests, and that with the wrong combination hands the repository keys to anybody who opens a pull request.
GitHub has decided to put its foot down with the most dangerous of them all, pull_request_target: from 2 December it will block it by default in public repositories. And the Python Software Foundation, which has good reasons to have learned its lesson, has explained on its blog how it removed it from its organisations ahead of the date, with a technical guide on the Alpha-Omega blog that is the most useful part of all this.
Why it’s dangerous
The difference between pull_request and pull_request_target is one word, and it changes everything. With pull_request, a PR coming from a fork runs with read-only permissions and no access to secrets. With pull_request_target, the workflow runs in the context of the target repository: a token with write permissions and access to secrets. It exists for legitimate things, like labelling PRs that come from forks, which need to write to the repository but never touch the contributor’s code.
The problem is when someone uses it to run the tests and, of course, to run the tests you have to check out the PR’s code. The dangerous pattern looks something like this (simplified from the PSF’s example):
on: pull_request_target
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }} # PR code
- run: make test # runs with the repository's secrets
Anybody can open a PR that modifies the Makefile (or the tests, or a conftest.py) to do whatever they want with the secrets. This is known as a pwn request, and as the PSF itself says, the unsafe version is one line away from the safe one: remove that ref: line and checkout fetches the target branch’s code, not the PR’s.
issue_comment carries a similar risk by a different route: workflows that put the text of a comment straight into a shell command, so the comment becomes code.
It isn’t theory
The PSF cites three incidents with PyPI packages:
| Project | When | What happened |
|---|---|---|
| Ultralytics | December 2024 | A pull_request_target workflow allowed the build cache to be poisoned, and malicious releases reached PyPI |
| LiteLLM and Telnyx | March 2026 | Malicious releases were published with a token exposed through a dependency, Trivy, which had itself fallen to a pull_request_target three weeks earlier |
| elementary-data | April 2026 | A comment-triggered workflow put the text into a shell script; with a crafted comment, the attacker pushed a malicious file and a tag, and the release pipeline published the result |
The Trivy one has a certain irony, if you can call it that: a security tool compromised through an unsafe workflow was used to compromise other projects. Supply chains are like that: every link inherits the problems of the ones before it.
How the PSF did it
Mike Fiedler and Seth Larson removed the dangerous triggers from the workflows and applied event policies across the psf, python and pypi organisations (in python a few repositories are still waiting to be migrated). The Alpha-Omega guide explains it step by step, and it’s worth following even if your organisation is small.
First, find where they’re used:
gh search code 'org:YOUR-ORG path:.github/workflows /pull_request_target|issue_comment/'
Second, create an event policy in the organisation’s Settings → Actions → Policies, starting in Evaluate mode, which blocks nothing and only records in Policy insights what it would have blocked. The guide recommends a list of allowed events rather than a list of forbidden ones:
{
"name": "Allow only expected workflow triggers",
"enforcement": "evaluate",
"conditions": {
"repository_name": { "include": ["~ALL"], "exclude": [] }
},
"rules": [
{
"type": "restrict_action_events",
"parameters": {
"allowed_events": ["pull_request", "push", "release", "repository_dispatch", "schedule", "workflow_dispatch", "workflow_run"]
}
}
]
}
gh api --method POST /orgs/YOUR-ORG/actions/policies --input policy.json
You leave it in evaluation long enough to cover a release cycle and the least frequent scheduled job, check what it would have broken, and then switch it to active. On the free plan organisation policies aren’t enforced, so they have to be created repository by repository (the guide includes the loop with gh repo list to do it in one go), with the drawback that new repositories won’t have it until somebody remembers.
For whatever really needed those triggers, the alternatives they suggest are:
- Labellers and welcome bots:
pull_request, and if the bot needs to write to the PR, split it into an unprivileged job withpull_requestand a privileged one withworkflow_run, or use a GitHub App. /deploy-style commands in comments:workflow_dispatch, which already checks the permissions of whoever triggers it.- Any artifact a
workflow_rundownloads from a PR: treat it as untrusted, and don’t useworkflow_runto publish anything.
What changes on 2 December
GitHub’s default rule is more modest than the PSF’s: it only blocks pull_request_target, only in public repositories (on Free, Team and Enterprise Cloud; private and internal repositories and GitHub Enterprise Server stay as they are), and it stops applying as soon as you define your own event policy. There have already been two test “brownouts”, on 9 and 16 November, during which the affected workflows failed for two hours. If any of your public repositories had a weird failure on those days between 16:00 and 18:00 UTC, now you know why.
If you really need pull_request_target, it can be allowed again with a policy that explicitly permits it. But before doing that I’d take a good look at the workflow: if it checks out the PR’s code, the answer is almost always to use pull_request and be done with it. And while you’re at it, a pass with zizmor, which the guide also recommends, finds this pattern and quite a few more, one repository at a time.
There’s one thing I really like about the PSF’s approach, which is that it doesn’t trust every maintainer to get their YAML right: it puts the protection at the organisation level, where a slip in one repository isn’t enough to open the door. Reviewing workflows one by one is fine, but a policy that stops the slip from ever running is better.




