How to Use the GitHub Actions Security Hardening Prompt to Close the Gaps Attackers Look For
Paste your workflow YAML files and get a security review that flags dangerous triggers, untrusted input inside run steps, unpinned third party actions, overly broad token permissions, and secrets reachable from fork pull requests, with a patched YAML for every finding.

GitHub Actions makes it easy to add automation, and just as easy to leave a door open. A workflow that runs on pull_request_target and checks out fork code, a run step that drops a pull request title straight into the shell, or a third party action pinned to a branch can each hand an outsider your secrets. The GitHub Actions Workflow Security Hardening Reviewer: pull_request_target Risks, Script Injection, Pinned Action SHAs, GITHUB_TOKEN Permissions, and Secret Exposure prompt reviews your workflow files the way a CI security engineer would and returns patched YAML for every finding.
What the prompt produces
- A trigger review that focuses on pull_request_target, workflow_run, and issue_comment, and whether untrusted code runs with secrets available.
- A script injection scan for run steps that interpolate pull request titles, branch names, comments, or commit messages directly.
- An action pinning table showing which actions use tags or branches instead of full commit SHAs.
- A permissions review with the least privilege set each job needs and a default of contents: read.
- Secret exposure paths, including secrets reachable from untrusted triggers and environments without required reviewers.
- Checkout hardening, such as persist-credentials set to false.
- Deploy auth notes on replacing long lived cloud keys with OIDC.
- A findings table followed by the patched YAML.
How to fill the inputs
WorkflowFiles should be the full YAML with paths. Partial snippets hide the trigger or permissions block, which is where many issues live.
RepoContext tells the prompt whether the repo is public, who can open pull requests, and whether fork pull requests run workflows. The same YAML can be safe in a private repo and risky in a public one.
SecretsAndEnvironments lists names only. Never paste secret values. Include which environments require reviewers.
ActionInventory lists third party actions and any org allow list.
DeployTargets explains where you deploy and how the workflow authenticates.
Reading the example output
The example is a public library with two workflows. The labeling workflow runs on pull_request_target, checks out the pull request head, runs npm ci, echoes the title, and calls a labeler pinned to main with a personal access token. The deploy workflow uses write-all permissions and long lived AWS keys.
The review splits the labeling workflow in two: an unprivileged pull_request job that lints fork code with no secrets, and a privileged pull_request_target job that only labels and never checks out pull request code. The title moves into an env variable. The labeler is pinned to a full SHA with a version comment, and the personal access token becomes GITHUB_TOKEN with pull-requests: write.
The deploy workflow drops to contents: read and id-token: write, switches to OIDC, and adds the production environment with required reviewers.
Tips for better results
- Paste every workflow, including old ones nobody remembers. Forgotten workflows are often the weak spot.
- Resolve commit SHAs from each action's official release page yourself. The prompt will not guess them.
- Pair the review with a linter such as actionlint or a workflow security scanner, then use the prompt to explain and fix what they flag.
- Re-run the review whenever you add a new trigger or third party action.
Mistakes to avoid
- Do not treat pull_request_target as a safer pull_request. It runs with secrets in the context of the base repo.
- Do not quote a variable and assume that fixes injection. Pass untrusted values through env.
- Do not keep a personal access token in a workflow when GITHUB_TOKEN with scoped permissions can do the job.
Who it is for
Open source maintainers, platform engineers, and security reviewers who own CI pipelines and want concrete patches rather than a checklist.
A practical routine
Collect the workflow folder, list secrets by name, and run the prompt. Fix critical and high findings in one pull request, pin actions in a second, and switch deploy auth to OIDC in a third so each change is easy to review and roll back.
Related PromptDig links
Open the GitHub Actions Workflow Security Hardening Reviewer: pull_request_target Risks, Script Injection, Pinned Action SHAs, GITHUB_TOKEN Permissions, and Secret Exposure prompt with your workflow files. For more developer prompts, Browse more prompts. If you have a CI review checklist your team trusts, Share a prompt.