With GitHub set to block pull_request_target by default in public repos on December 2, and the PSF’s write-up on why, I went through my own repos (I keep my Ansible playbooks and bot scripts in Git). Here’s the quick audit I ran.
1. Find the triggers
From a folder with your repos cloned:
grep -RnE 'pull_request_target|issue_comment|workflow_run' --include='*.yml' --include='*.yaml' */.github/workflows/
2. For each hit, ask three questions
- Does it check out or run the pull request’s code (for example
ref: ${{ github.event.pull_request.head.sha }})? If yes withpull_request_target, that’s a “pwn request.” Fix it first. - Does it paste untrusted text (comment body, PR title, branch name) into a
run:step via${{ }}? Move it into an environment variable and quote it instead. - Does it need secrets or write access at all? If not, switch to plain
pull_request.
3. Lock down the token
Add a top-level permissions block to every workflow and only grant what a job needs:
permissions:
contents: read
And in repo settings (Actions > General), set the default workflow permissions to read-only.
4. Don’t persist credentials you don’t need
- uses: actions/checkout@v6
with:
persist-credentials: false
5. Then apply the policy
On Team/Enterprise you can block the dangerous triggers org-wide; on Free, repo by repo. The PSF’s advice is the right order: set the policy, see what it would block, then enforce. Re-run the grep after.
God Bless, and Use the Source!