138% more reported CVEs per day in 2026 than last year.New: always-on Fixboxes. Vulnerable dependencies, fixed and verified.

CI/CD security

GitHub Actions security: a checklist for hardening your workflows

A GitHub Actions workflow runs code from many authors with your repository's token, your secrets and a path to production. Most of the controls that keep it safe are built into GitHub, but they are off, loose or easy to get wrong by default. This checklist covers each one: what to set, why it matters and the incident that shows what happens without it.

Updated

The checklist at a glance

Item What it stops
Least-privilege GITHUB_TOKEN A hijacked step pushing code, publishing releases or triggering other workflows
Pin or lock third-party actions A moved tag running an attacker's code in your job
Treat pull_request_target and workflow_run as privileged Pwn requests: fork code running with your secrets
Keep event data out of run scripts Script injection through titles, branch names and comments
OIDC instead of stored cloud keys Long-lived credentials that work for years after they leak
Environments with required reviewers Any branch or workflow reading production secrets
Code owners on .github/workflows Unreviewed changes to what the pipeline runs
Allowed actions policy Unknown or unpinned actions anywhere in the organization
No self-hosted runners on public repositories Strangers running code on your machines
Cache and artifact hygiene Poisoned caches and tokens leaking through uploads
Egress control on runners Stolen secrets being sent to an attacker's server
A record of each run Not knowing which builds ran a compromised action or package

Workflow code

1. Give GITHUB_TOKEN the least privilege

Every job gets a GITHUB_TOKEN, and any step in the job can use it. Repositories and organizations created before February 2023 can still default to read and write on every permission. Set the default to read-only under Settings → Actions → General → Workflow permissions, then grant write access per job:

permissions:
  contents: read

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@<full-commit-sha>

Anything you do not list becomes none. For each permission and what common tasks need, see GITHUB_TOKEN permissions: least privilege for every workflow.

2. Pin third-party actions to a commit, or lock them

A tag such as @v4 is a pointer the action's owner, or anyone who steals their access, can move. Two incidents show what that means:

  • tj-actions/changed-files, March 2025. An attacker changed existing version tags to point at a malicious commit (CVE-2025-30066). The action was used by more than 23,000 repositories, and the payload printed secrets from runner memory into the workflow logs, which anyone can read on a public repository.
  • aquasecurity/trivy-action, March 2026. Aqua Security's advisory (CVE-2026-33634) says 76 of the action's 77 version tags were force-pushed to malicious commits. The injected code ran before the real scan, read secrets from runner memory and sent them, encrypted, to the attacker's infrastructure.

Workflows that referenced a full commit SHA kept running the code they had before. Keep the version as a comment:

steps:
  # Mutable: whoever controls the tag decides what runs
  - uses: tj-actions/changed-files@v45
  # Immutable: a full commit SHA, with the version as a comment
  - uses: tj-actions/changed-files@<full-commit-sha> # v46.0.1

Check that the SHA comes from the action's own repository, not a fork. GitHub now offers something stronger: workflow dependency lockfiles, generally available since October 28, 2026. The gh actions-lock CLI extension writes .github/workflows/actions.lock, which records the exact commit for every action your workflows use, including the actions those actions call, and GitHub checks at run time that each source repository is still the one you locked. Calls to reusable workflows are not covered, so pin those by SHA. Administrators can require a lockfile by policy. Neither pinning nor a lockfile makes an action safe: review what you lock.

Pinned actions do not update themselves. Let Dependabot propose updates, with a cooldown so a new release has a few days to be caught before it reaches you:

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
    cooldown:
      default-days: 7

3. Treat pull_request_target and workflow_run as privileged

A pull_request workflow from a fork gets a read-only token and no secrets. A pull_request_target workflow runs in the context of the base repository, with its secrets and a token that can write, even when the pull request comes from a fork. That is safe only while the workflow never runs code from the pull request. Check out the pull request's head and build it, and every install script and test in that pull request runs with your secrets. GitHub Security Lab calls these pwn requests.

  • Use pull_request for anything that builds or tests contributed code.
  • If a privileged step must follow, such as commenting on the pull request, split it: an unprivileged pull_request workflow uploads its results as an artifact, and a workflow_run workflow acts on them. Treat those artifacts as untrusted input, never as code to run.
  • In public repositories without an event policy, GitHub blocks pull_request_target by default from December 2, 2026. If you allow it again, allow only the workflows that need it.

The TanStack compromise in May 2026 started this way: a pull_request_target workflow ran fork code, which poisoned the cache a release workflow later restored, and an OIDC token read from runner memory was used to publish 84 malicious versions of 42 packages.

4. Keep event data out of run scripts

Expressions are expanded before the shell runs, so a pull request title, branch name, issue body or commit message inside run becomes part of the script. Anyone who can open a pull request or an issue can then run commands in your job. Pass the value through an environment variable, so the shell treats it as data:

# Vulnerable: the title is pasted into the script before the shell runs
- run: echo "Checking ${{ github.event.pull_request.title }}"

# Safe: the shell reads the title as data
- env:
    PR_TITLE: ${{ github.event.pull_request.title }}
  run: echo "Checking $PR_TITLE"

The same applies to actions/github-script and to values written to GITHUB_ENV. AI agents in workflows add a new form of the same problem: text in an issue can steer the agent instead of the shell. See prompt injection.

Secrets and deployments

5. Use OIDC instead of long-lived cloud keys

A cloud access key stored as a secret works until someone rotates it, which after a leak is often too late. With OpenID Connect the job asks GitHub for a short-lived token and exchanges it with AWS, Azure or Google Cloud, whose trust policy decides which repository, branch or environment may assume the role:

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: aws-actions/configure-aws-credentials@<full-commit-sha>
        with:
          role-to-assume: arn:aws:iam::123456789012:role/deploy
          aws-region: us-east-1

A short-lived token can still be stolen from a running job, as TanStack showed, but it is worth far less than a key that never expires. Pass the secrets you do keep to the step that needs them rather than the whole job, so other actions in the job cannot read them. How secrets leak and the rest of the controls are in GitHub Actions secrets: how they leak and how to lock them down.

6. Put production behind environments with required reviewers

An environment holds its own secrets, and a job that names it cannot read them until a required reviewer approves the run. Deployment branch rules limit which branches may use it at all. A workflow on a feature branch, or one triggered by a pull request, then has no route to production credentials.

Governance

7. Require code owner review for workflow files

A workflow file decides what runs with your secrets, so a change to it deserves the same review as a change to production access. Add the folder to CODEOWNERS and require code owner review in a branch ruleset:

/.github/workflows/ @example-org/platform-security
/.github/actions/ @example-org/platform-security

8. Restrict which actions can run

At enterprise, organization or repository level, the allowed actions policy can limit actions to those from GitHub, verified creators or a list you maintain. Since August 2025 it can also require SHA pinning, so a workflow that uses an unpinned action fails, and block a specific action or version with a ! entry, which helps the day an action you use is reported compromised.

Runners, caches and artifacts

9. Keep self-hosted runners off public repositories

GitHub's secure use reference says self-hosted runners should almost never be used for public repositories, because anyone can open a pull request and run code on them. On private repositories, use runners that start fresh for each job: a long-lived runner keeps whatever one job leaves behind for the next, including a backdoor. The Shai-Hulud npm worm registered infected machines as self-hosted runners for exactly that reason. See managed vs self-hosted runners.

10. Protect caches from poisoning

Caches are scoped by branch, and caches saved on the default branch can be restored by every other branch. Code that runs in any workflow on the default branch can therefore write cache entries that a release workflow restores later, without needing a write token. Keep untrusted code out of default-branch workflows, avoid restoring caches in release and publishing jobs, and rebuild from a lockfile there instead. See how the GitHub Actions cache works.

11. Handle artifacts as untrusted

actions/checkout keeps the token on disk for later git commands unless you turn it off. Uploading the workspace as an artifact has leaked that token in the past. Set persist-credentials: false on checkouts that do not push, upload only the paths you need, and never run an artifact from a pull request in a privileged workflow:

- uses: actions/checkout@<full-commit-sha>
  with:
    persist-credentials: false

Network and records

12. Control where jobs can connect

GitHub-hosted runners do not restrict outbound traffic, so code in a job can send what it reads anywhere. Most jobs need a short list of destinations: package registries, container registries, source hosts and a few APIs. Allow those and block the rest, and a stolen secret has nowhere to go, even in an attack nobody has seen before. An egress policy does not stop secrets printed to logs, as in the tj-actions case, which is why it belongs next to pinning, not instead of it. See how an egress policy stops exfiltration from GitHub Actions.

13. Record which actions and packages each run used

When the next compromised action or package is announced, the first question is which of your runs used it. A workflow file says what a run was meant to use. A tag, a version range or a cache hit can make the answer different, and the record that settles it is the one taken while the job ran: the commit of each action, every package fetched or restored from a cache, and the connections the job made. See SBOMs in GitHub Actions.

Free tools that audit your workflows

Most of the workflow items above can be checked automatically. These tools read workflow files; they do not watch a job while it runs.

Tool What it checks
zizmor Static analysis for GitHub Actions, Dependabot and pre-commit configuration: template injection, dangerous triggers, excessive permissions, unpinned actions, impostor commits, cache poisoning and credentials left by checkout
actionlint A linter for workflow syntax and expressions that also flags untrusted values used in inline scripts and runs shellcheck on run steps
OpenSSF Scorecard Repository checks including Dangerous-Workflow (untrusted checkouts and script injection), Token-Permissions and Pinned-Dependencies
poutine BoostSecurity's open-source scanner for build pipelines, covering GitHub Actions, GitLab, Azure DevOps and Tekton, and able to scan every repository in an organization
CodeQL GitHub's code scanning, which has analyzed workflows for injection and pwn request patterns since 2025

Run one of them in pull requests that touch .github/. For how these fit with runner controls and posture tools, see CI/CD security tools compared and CI/CD security. For a checklist that covers the whole pipeline rather than GitHub Actions settings, see the CI/CD pipeline security checklist.

How CRACI helps

CRACI replaces the runner, not GitHub Actions: you change runs-on to craci, and the workflows, secrets, token permissions and run history stay in GitHub. It covers the last items on this list, the ones that happen while a job runs:

  • Egress control. An egress policy decides which package sources, registries and hosts a job may reach. It is validated before the job starts, enforced at the runner and fails closed, and a blocked connection raises an alert.
  • A record of each run. The job's SBOM lists the GitHub Actions it ran as pkg:github components pinned to the commit used, and every package it fetched, including packages restored from a cache, with a trace of its network connections. When an action's tags are moved, you can see which commit each run actually executed.
  • Policy gates. A build that pulls in a package with a known vulnerability, including a specific CVE, can be stopped.
  • Isolation. Each job runs in its own virtual machine, so nothing carries over to the next.

CRACI does not audit your workflow files, scan source code or scan for secrets, so keep a workflow linter such as zizmor, GitHub's secret scanning and your SAST tool for those. It runs GitHub Actions jobs on Linux, and other CI systems are on the roadmap.

GitHub Actions security: frequently asked questions

How do I secure GitHub Actions?

Set GITHUB_TOKEN to read-only and grant write per job, pin or lock third-party actions, avoid running pull request code in pull_request_target workflows, pass event data to scripts through environment variables, use OIDC instead of stored cloud keys, put production secrets behind environments, require review of workflow files, and control what jobs can connect to.

Should I pin GitHub Actions to a commit SHA?

Yes, for third-party actions. A tag can be moved to other code, as happened with tj-actions/changed-files in 2025 and trivy-action in 2026, while a full commit SHA cannot. GitHub's workflow lockfiles go further and lock the actions that your actions call too.

Is pull_request_target dangerous?

It is safe only if the workflow never runs code from the pull request. It runs with the base repository's secrets and a write token even for forks, so building fork code in it hands both to whoever opened the pull request. GitHub blocks it by default in public repositories without an event policy from December 2, 2026.

What is a pwn request?

GitHub Security Lab's name for a privileged workflow, usually triggered by pull_request_target, that checks out and runs untrusted code from a pull request, giving the author access to the workflow's secrets and token.

Are workflow lockfiles better than SHA pinning?

They are stronger. A lockfile records the commit of every action a workflow uses, including transitive ones, and GitHub checks the source repository's identity at run time. Reusable workflow calls are not covered, so pin those by SHA.

Which free tools check GitHub Actions workflows for security issues?

zizmor, actionlint, OpenSSF Scorecard and poutine are free, and CodeQL can analyze workflows as part of GitHub code scanning. They read workflow files; they do not control what a job does while it runs.

See what one of your workflows actually ran

Run a GitHub Actions job on CRACI and get the commit of every action, every package fetched and an egress policy that fails closed.

Book a demo