Join our Newsletter — 33% off our NHI Course
Home› Guides› Top 10 GitHub Actions Security Mistakes: pull_request_target, Unpinned…
Top 10 Software & AI Supply Chain

Top 10 GitHub Actions Security Mistakes: pull_request_target, Unpinned Actions and Token Scope

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 12 min read
On this page

GitHub Actions workflows are code that runs with credentials, so a single unsafe trigger, an unpinned third-party action or a default write token can turn a pull request into a route to your secrets, your cloud accounts and your releases. This Top 10 ranks the workflow mistakes that most often create that route, and gives the configuration change that closes each one.

The list is for platform engineers, repository administrators and security teams who review workflow files. It is deliberately short on theory. For the full GitHub credential model, runners and organisation controls, see the GitHub and GitHub Actions Security Guide, and for pipeline security beyond GitHub, see the CI/CD Security Guide.

This is an independent guide from NHI Mgmt Group, based on GitHub's public documentation as of November 2026. It is not sponsored or reviewed by GitHub. Product features change, so confirm settings against GitHub's current documentation.

Key takeaways

  • Every workflow run is a non-human identity: the GITHUB_TOKEN, repository secrets and any cloud credentials it can reach are its permissions.
  • pull_request_target runs "in the context of the default branch of the base repository", with access that ordinary fork pull requests do not get. Combined with a checkout of the pull request code, it hands that access to the contributor.
  • Untrusted values such as pull request titles must never be inlined into run: scripts. Pass them through an environment variable.
  • Tags on third-party actions can be moved. GitHub advises pinning to a full-length commit SHA.
  • Set the default GITHUB_TOKEN to read-only and grant write scopes per job.
  • Replace long-lived cloud keys in secrets with OpenID Connect (OIDC) federation.

The Top 10 at a glance

The ranking is an NHI Mgmt Group judgement combining how common each mistake is in public and private repositories and how much access it typically exposes.

RankMistakeFix in one line
1pull_request_target with a checkout of untrusted codeUse pull_request, or split privileged steps into workflow_run
2Script injection from untrusted expressionsPass values through environment variables
3Third-party actions referenced by tag or branchPin to a full-length commit SHA
4Default write GITHUB_TOKENRead-only default, per-job permissions:
5Long-lived cloud credentials in secretsOIDC federation with tight trust conditions
6Self-hosted runners on public repositoriesGitHub-hosted or just-in-time runners, runner groups
7Poor secret hygiene in workflowsOne secret per value, mask derived values, rotate on exposure
8Trusting artifacts from untrusted runsTreat downloaded artifacts as untrusted input
9Workflow files without review protectionCODEOWNERS on .github/workflows
10No continuous checking of workflows and actionsDependabot, dependency review and Scorecards

1. pull_request_target with a checkout of untrusted code

The pull_request trigger is designed for untrusted contributions. GitHub documents that for workflows triggered from a forked repository, secrets other than GITHUB_TOKEN "are not passed to the runner", and the GITHUB_TOKEN "has read-only permissions in pull requests from forked repositories".

pull_request_target is different. It runs "in the context of the default branch of the base repository", which is what lets it label pull requests or post comments. GitHub warns that running untrusted code in this context "may lead to security vulnerabilities" such as "granting unintended access to write privileges or secrets", and advises: "Avoid using this event if you need to build or run code from the pull request."

The classic mistake is a workflow on pull_request_target that checks out the pull request head and then runs a build, test or install step. The contributor's code, including build scripts and dependency hooks, then runs with the privileges of the base repository.

Fix: use pull_request for anything that builds or runs contributed code. If you need privileged follow-up actions, GitHub's hardening guidance prefers workflow_run for privilege separation: an unprivileged workflow does the build, and a separate privileged workflow acts on the result without executing contributed code. Never check out untrusted pull request code in a privileged workflow.

2. Script injection from untrusted expressions

Expressions such as ${{ github.event.pull_request.title }} are expanded before the shell runs. If a workflow places that expression directly inside a run: block, an attacker who controls the title, branch name, issue body or commit message can inject shell commands.

GitHub's guidance is to "set the value of the expression to an intermediate environment variable" and reference that variable in the script, or to use an action that receives the value as an argument so that it "is not used to generate a shell script".

Fix: search every workflow for ${{ github.event inside run: blocks and move those values into env:. Treat issue and comment triggers as untrusted in the same way as pull requests. The GitHub Actions Script Injection Guide covers the patterns in depth.

3. Third-party actions referenced by tag or branch

A reference such as uses: some-org/some-action@v3 trusts whoever controls that tag today. GitHub notes that pinning to a tag is riskier because "a tag can be moved or deleted" if an attacker gains access to the action's repository. Branch references are worse, because they change with every push.

GitHub advises pinning to a full-length commit SHA and confirming that the SHA comes from the action's own repository rather than a fork. Its documentation also describes lockfiles as "the strongest protection available", superseding SHA pinning for repositories that adopt them. Either way, audit the action's source, especially how it handles secrets.

One trade-off matters: GitHub states that Dependabot "will not create alerts for actions pinned to SHA values". Pinning therefore needs a separate update process, such as Dependabot version updates, so pinned actions do not silently age.

Fix: pin every third-party action to a full SHA with a version comment, enforce allowed actions at organisation level, and keep pinned references current. See How to Pin GitHub Actions to Commit SHAs for a step-by-step method, and the Third-Party GitHub Action Compromise Response Playbook for what to do when an action you use is compromised.

4. Default write GITHUB_TOKEN

Each job receives a GITHUB_TOKEN. If the repository or organisation default grants write access, every job, including test and lint jobs that only need to read, can push code, change releases or modify issues. A single injection or compromised action in any job then has write access.

GitHub recommends setting the default GITHUB_TOKEN permission to read-only for repository contents and granting more per job only when needed, noting that restricting permissions also limits the damage from an exposed token.

Fix: set the organisation default to read-only, add a top-level permissions: {} or contents: read block to every workflow, and grant contents: write, id-token: write or other scopes only on the specific job that needs them.

5. Long-lived cloud credentials in secrets

Storing cloud access keys as repository or organisation secrets creates long-lived credentials that any workflow with access can read, and that persist until someone remembers to rotate them. GitHub recommends using OpenID Connect to authenticate to cloud providers so you can stop storing long-lived cloud credentials as secrets.

OIDC only helps if the trust policy on the cloud side is tight. A role that trusts any repository in an organisation, or any branch, recreates the same over-broad access with a new mechanism. GitHub's guidance also notes that custom OIDC claims are not supported in AWS, which affects how you design conditions there.

Fix: move cloud deployments to OIDC, scope each cloud role to a specific repository and branch or environment, require id-token: write only on deployment jobs, and delete the old keys once migration is complete. See the GitHub Actions OIDC Federation Hardening Guide.

6. Self-hosted runners on public repositories

Self-hosted runners give workflows access to your network, your caches and whatever else lives on the host. GitHub's guidance is that self-hosted runners should almost never be used for public repositories, because anyone can open a pull request and persistently compromise the runner. Even on private repositories, people who can fork and open pull requests may be able to reach secrets and the GITHUB_TOKEN.

Fix: use GitHub-hosted runners for public repositories; for private repositories, use runner groups to limit which repositories can reach which runners, prefer just-in-time runners that are discarded after one job, and clean or reimage hosts between jobs because re-used hardware can leak information. Keep runners off networks that hold production credentials.

7. Poor secret hygiene in workflows

GitHub redacts registered secrets from logs, but it warns that redaction is not guaranteed. Common mistakes include storing a JSON, XML or YAML blob as a single secret, deriving new values (such as a Base64-encoded token) without registering them as secrets, and echoing values for debugging.

GitHub's guidance is to create a separate secret for each sensitive value, register derived values as secrets too, mask other sensitive values with ::add-mask::, and, if a secret reaches a log, delete the log and rotate the secret. Environments with required reviewers can gate access to environment secrets.

Fix: split structured secrets, use environment secrets with required reviewers for production, keep secrets out of workflow files entirely, and build a rotation runbook for exposure events. These are non-human identity credentials and belong in your secrets inventory.

8. Trusting artifacts from untrusted runs

Privilege separation with workflow_run only works if the privileged workflow treats what it receives as untrusted. GitHub advises caution with artifacts from other workflows when using workflow_run. If the privileged workflow downloads an artifact built from a contributor's pull request and then executes it, extracts it over trusted files, or reads values from it into a shell command, the separation is lost.

Fix: in privileged workflows, parse artifacts as data only, validate their content and format, never execute them, and extract them to a separate directory. Avoid uploading files that contain tokens or credentials as artifacts in the first place.

9. Workflow files without review protection

A workflow file controls what runs with your secrets. If anyone with write access can change .github/workflows without a specific review, a compromised developer account or a well-meaning change can widen permissions or add an exfiltration step.

GitHub recommends adding .github/workflows to the CODEOWNERS file so changes to workflow files require approval from a designated reviewer. For public repositories, GitHub also notes that a maintainer with write access may need to approve running workflows on pull requests from first-time contributors.

Fix: add CODEOWNERS for workflow files, require code owner review through branch protection or rulesets, and keep approval for workflows from outside contributors switched on.

10. No continuous checking of workflows and actions

Workflows drift. New jobs are added, actions age, and permissions creep. Without automated checks, mistakes one to nine come back.

GitHub points to Dependabot version updates to keep action references current, dependency review on pull requests to show the security impact of action changes, and OpenSSF Scorecards, whose checks include "script injection attacks, token permissions, and pinned actions".

Fix: enable Dependabot for the github-actions ecosystem, run dependency review on pull requests, run Scorecards or an equivalent workflow linter on every repository, and report the results to repository owners with clear deadlines.

Mapping to frameworks

FrameworkReferenceRelevance
OWASP Top 10 CI/CD Security RisksPoisoned Pipeline Execution; Insufficient Credential Hygiene; Ungoverned Usage of 3rd Party ServicesMistakes 1 to 3, 5 and 7
MITRE ATT&CKT1195.002 Compromise Software Supply ChainCompromised actions and poisoned builds
MITRE ATT&CKT1552.001 Credentials In FilesSecrets in workflow files and logs
NIST SP 800-204DSoftware supply chain security in CI/CD pipelinesOverall pipeline integrity
NIST SP 800-53 Rev. 5AC-6 Least PrivilegeToken scope, runner scope and OIDC trust

The Top 10 CI/CD Security Risks covers each OWASP CI/CD risk in turn.

Common failure patterns

  • Copy and paste workflows. A workflow from a blog post or another repository brings its triggers and permissions with it, unreviewed.
  • Bot convenience. pull_request_target is chosen because it "just works" for labelling, then later gains a build step.
  • Pin once, never update. Actions are pinned to SHAs and then never updated, because Dependabot alerts do not cover SHA-pinned actions.
  • OIDC with wildcard trust. Federation replaces keys, but the cloud role trusts every repository in the organisation.
  • Organisation defaults left alone. Each repository fixes token permissions individually, while new repositories inherit the old write default.
  • Runners as pets. Long-lived self-hosted runners accumulate credentials, caches and tools across jobs.

Practitioner checklist

  • List every workflow using pull_request_target or workflow_run and confirm none executes contributed code with privileges.
  • Move every ${{ github.event... }} value out of run: blocks and into env:.
  • Pin all third-party actions to full commit SHAs and set an allowed actions policy at organisation level.
  • Enable Dependabot version updates for the github-actions ecosystem.
  • Set the organisation default GITHUB_TOKEN to read-only and add explicit permissions: to each workflow.
  • Replace cloud access keys with OIDC and scope each cloud role to a repository and branch or environment.
  • Remove self-hosted runners from public repositories and use runner groups and just-in-time runners elsewhere.
  • Split structured secrets, register derived values and rotate any secret that appeared in a log.
  • Protect production secrets with environments and required reviewers.
  • Add .github/workflows to CODEOWNERS and require code owner review.
  • Run OpenSSF Scorecards or an equivalent check on every repository and track findings to closure.

Standards and references

Related NHI Mgmt Group resources: GitHub and GitHub Actions Security Guide · CI/CD Security Guide · How to Pin GitHub Actions to Commit SHAs · Top 10 CI/CD Security Risks

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.