How a workflow run works, what an attacker gets when one goes wrong, and how to lock it down, with most of the attention on version pinning. The Best Practices page has the baseline hardening examples (least-privilege permissions, safe pull_request_target, script injection, OIDC). This page goes further on why those matter and where they fall short.
How a run works
Every workflow run is the same chain. Something fires an event, GitHub picks a workflow file from some ref, hands a runner a token and the secrets the job asks for, and then executes every step in order. Nothing separates your own build script from a third-party action in step three: they share the filesystem, the environment, the network, and the process memory where secrets live.
1
Event
A push, PR, comment, schedule, or API call. Decides who is effectively running your CI.
2
Workflow file
Read from a ref the event decides. For a fork PR that can be the attacker's copy.
3
Runner
A fresh VM (hosted) or your own machine (self-hosted), given a token and the job's secrets.
4
Steps
Your scripts and every third-party action, all in the same process space with the same access.
5
Side effects
Pushes, releases, packages, cache entries, artifacts, cloud deploys. The real blast radius.
Security questions map onto that chain. Who can fire the event? Which copy of the workflow runs? What does the token let the job do? Which code, from whom, runs in the steps? And what can the job change afterwards? Almost every Actions incident on this site is one of those questions answered badly.
Triggers and who controls them
The trigger is the trust decision. It decides whether an outsider can start the run, whether their copy of the workflow is used, and whether the run gets secrets. The dangerous combination is always the same: a trigger that runs with secrets, plus a step that runs or reads something an outsider controls.
Trigger
Who can fire it
Workflow file from
Fork run gets
Watch for
Attack technique
pull_request
Anyone who can open a PR, including from a fork
The PR's merge commit, so the PR author controls the workflow file
Read-only GITHUB_TOKEN, no secrets
Safe by design for forks. The risk is a same-repo branch PR, which gets secrets, or a later privileged workflow that trusts this run's output.
A write-access user can add a new workflow on any unprotected branch and read every secret it references. Write access is effectively secrets access unless deploy secrets live in protected environments.
Low exposure, but these jobs often hold broad tokens for maintenance and quietly keep running long after anyone looks at them.
Two things that catch people out. First, a pull request from a branch in the same repository is not a fork PR, so it gets secrets. Anyone with write access can open one with a modified workflow. Second, the privileged triggers (pull_request_target, workflow_run, issue_comment) are fine on their own. They become a pwn request when a step checks out the PR, restores a cache the PR could have written, or puts a title or comment into a shell.
What an attacker gets inside a job
Once untrusted code runs in a step, whether through a compromised action, a malicious dependency, or script injection, it has everything the job has. Assume all of this is gone:
The GITHUB_TOKEN
With whatever permissions the job was given. On actions/checkout before v6 it was also written to .git/config, where any later step or uploaded artifact could pick it up (the ArtiPACKED finding).
The runner process holds them in memory in plain text. Log masking doesn't help: the tj-actions payload read them straight out of the Runner.Worker process memory.
The takeaway is that the blast radius of a job is decided before it starts: by its token permissions, the secrets it references, its OIDC trust, and the runner it lands on. Reducing any of those helps even when every other control fails.
Getting secrets out, end to end
No token can read an Actions secret through the API: it returns names, and the write permissions only overwrite values. The only way to a value is to run code in a job that receives it, and send it somewhere. So the question for every secret is who can make such a job run code they chose, and what GitHub checks before it hands the secret over.
Where a secret lives decides which jobs get it
Secret
Given to
What guards it
Fix
Repository secrets
Every workflow run in the repository, except pull_request runs from forks and runs Dependabot starts, which get Dependabot secrets instead.
Nothing beyond who can make a run execute code they wrote. GitHub's own docs say anyone with write access can read them.
Only jobs that name the environment, and only once its deployment branch policy and required reviewers let the job through.
Required reviewers hold even against a push a workflow already acts on. A branch policy holds only while nobody can push a branch or tag it allows, and Protected branches only allows every branch in a repository without branch protection. An admin can change both, and bypasses them unless the environment turns bypass off.
The common case: a stolen personal token or App token that can push but has no Workflows, Actions or Administration permission.
Can it
Answer
Why
Read a secret through the API
No
No token can. The API lists names, and Secrets: write and Environments: write overwrite values without reading them.T1Secrets: WriteT1Environments: Write
Change a workflow file
No
A token also needs Workflows: write to change anything under .github/workflows. A person with the Write role pushing with their own login has no such limit.T1Workflows: WriteT1Write
Change what a workflow runs
Yes
Build scripts, tests, package manifests and local actions outside .github/workflows are ordinary files. Pushed to a new branch, an existing push workflow runs them with its secrets.The escalation ↗
Start a run
Yes
A push starts the push workflows, and repository_dispatch starts the default branch's workflows on that event. workflow_dispatch needs Actions: write. A push made with a GITHUB_TOKEN starts nothing; repository_dispatch still does.T1Actions: WriteThe escalation ↗
Change an environment's reviewers or branch policy
Only if a push workflow already has a job that names the environment, the environment has no required reviewers, and its branch policy lets your branch through: no policy, a name pattern you can create, or Protected branches only in a repository with no branch protection.
Get organization secrets
Yes
The ones shared with this repository that the workflow uses arrive the same way as repository secrets.
Every way to a secret
Each row starts from some access and ends with a job that runs the attacker's code with secrets in it. The last column is what an environment with a branch policy and required reviewers does to that route.
Commit a workflow, or change an existing one, that runs on push and sends the repository's secrets out. The workflow also sets its own token permissions, including id-token: write.
Push a new branch that changes a file an existing push workflow runs: a build script, a test, a package manifest, or a local action outside .github/workflows. The workflow file stays as it is, so no Workflows permission is needed. A push made with a GITHUB_TOKEN starts no run, so this takes a personal token, an App token or a person's own push.
Send a repository_dispatch event with a client_payload you write. It runs the default branch's workflows on that event with their secrets, and unlike a push it starts a run even when sent with a GITHUB_TOKEN. The payload is only a way in when the workflow puts it into a shell or checks out the ref it names.
Create a deployment for a branch or commit you chose. A workflow on the deployment event runs at that commit, and its job gets the environment's secrets unless a deployment branch policy or required reviewers stop it.
A branch policy stops it unless the commit's branch passes. Approving the job yourself works only as a required reviewer, and only when self-review is allowed.
Remove the environment's required reviewers, widen its deployment branch policy, or force a run through with the administrator bypass, which is on unless the environment turns it off. It still takes a way to run a job that names the environment, such as Workflows: write or a push a workflow already acts on.
Add a repository whose workflows you can change to an organization secret shared with selected repositories. The value is never needed: the next workflow run in that repository receives it and can send it out.
Push to the repository that holds a reusable workflow other repositories call by branch or tag. Reusable workflows live in .github/workflows, so changing one needs Workflows: write. Callers that pass secrets: inherit hand it every secret they have.
Create a runner registration token or a just-in-time configuration and register a machine the attacker controls, with the labels existing jobs ask for. A job goes to any available runner in its group that has all its labels.
A pull_request_target or workflow_run job checks out the attacker's PR, or interpolates its title into a shell step, and the attacker's code runs with secrets in scope.
A backdoored Action or a process on a reused runner reads secrets out of runner memory or from .git/config, and prints them to logs or uploads them as artifacts.
No help: the code is already inside the job that was approved.
Some routes need no permission at all, and code already inside an approved job, or a runner the attacker registered, gets past every environment rule. Required reviewers still stop more of these routes than anything else, which is why production secrets belong in an environment that has them, and cloud access belongs in OIDC, where there is no stored value to send anywhere.
GITHUB_TOKEN scopes by tier
Each scope you add to a job's permissions: block is handed to every step in that job. These are the permissions a workflow can ask for, from the Permission Reference, on the same scale as everything else. The token only reaches the repository the workflow runs in and expires when the job ends (at most 24 hours), so none of them is Tier 0 on its own.
Starts workflows that have a workflow_dispatch trigger, on any branch that holds the file, with its own inputs. Also re-runs, cancels and deletes runs, approves runs from fork pull requests, disables workflows, deletes logs, caches and artifacts, and sets the repository's OIDC subject template. A re-run keeps the privileges of whoever started the original run and uses the workflow file from the original commit; re-running a run Dependabot started still gets Dependabot secrets. Starting a privileged publish or deploy job by hand was the step that mattered in the Nx incident.
Lets the job request an OIDC token. The token grants nothing on GitHub; a cloud role whose trust policy accepts it hands out credentials. What the job gets is that role's permissions, and which jobs get it depends on how closely the policy matches the subject and audience.
Publishes, deletes and restores package versions. Only the GITHUB_TOKEN has it: a workflow reaches a package linked to its repository, or one that gave the repository Actions access; Maven and Gradle packages always follow the repository. Whatever is published is pulled by everyone who depends on it.
Creates and overwrites the organization's storage and deployment records for artifacts, including their runtime risks. Alert filters and security campaigns use them to show which code runs in production, so marking an artifact decommissioned or dropping a risk pushes its alerts down the list.
Uploads attestations and deletes them, for the repository and across the organization. A verifier checks the signing certificate, which names the repository and workflow that got it through Actions OIDC, so uploading alone does not make a forged artifact pass. Deleting one makes a genuine artifact fail verification.
Creates, completes and re-requests check runs and suites. A check run satisfies a required check of the same name unless the rule pins a different App as its source.
Pushes commits, creates, moves and deletes branches, tags and releases, merges pull requests, and sends repository_dispatch events. Cannot change files under .github/workflows without Workflows: write. On a repository other projects consume, moving a tag changes what they run, unless the tag belongs to an immutable release: its tag and assets are locked, though the release can still be deleted.
Creates and deletes deployments for any branch, tag or commit, sets their statuses, and approves or rejects pending jobs where the caller is a required reviewer or the custom protection rule. A deployment triggers workflows on the deployment event at the commit it names, and a success status can satisfy a rule that requires deployments to succeed before merging. A deployment branch policy on the environment limits which refs can deploy.
Rebuilds the site from the default branch, cancels deployments, and deploys an Actions artifact to the site. A deployment also needs an OIDC token issued to a workflow run in the same repository, so new content goes out through a Pages workflow, not the API alone; the call itself can come from outside the run while the token is valid. Changing the site's source, custom domain or HTTPS also needs Administration (write).
Sets commit statuses. A required status check set to any source can be marked green by anyone with this; one pinned to a GitHub App only accepts that App's status.
Reads workflow runs, job logs and artifacts, lists caches without their contents, and reads environment protection settings and the repository's OIDC subject template. On a public repository anyone can already read the logs and artifacts. GitHub does not guarantee that secrets are masked in logs, and structured or encoded values often are not.
A workflow with no permissions: key falls back to the repository default, which on older orgs is often read/write on nearly everything. Setting the org default to read-only and writing an explicit block per job is the single cheapest change on this page.
Version pinning
A uses: line is a dependency on someone else's repository, fetched fresh on every run. What you pin to decides who can change the code your job runs, and whether you would notice.
Reference
Example
Who can change what runs
Attack technique
Branch
actions/checkout@main
Anyone who can push to that branch in the action's repo, at any time
Tag
actions/checkout@v6
Anyone with write access to the action's repo. Tags can be moved or recreated silently, which is what tj-actions and TeamPCP did
owner/action@v2.1.0 (release published as immutable)
Nobody, the tag is locked to its commit and can't be deleted. Floating major tags like v2 are still mutable
Full commit SHA
actions/checkout@<40-char sha> # v6.0.1
Nobody. Changing the code means a new SHA, which means a visible diff in your repo
Pin to a SHA and keep the version as a comment
GitHub's own guidance calls a full-length SHA the only way to use an action as an immutable release. The trailing comment is what makes pins reviewable and lets Dependabot and Renovate update them.
For the first pass across many repositories, a tool like pinact rewrites tag references to SHA plus comment in place. After that, let Dependabot keep them current:
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # covers .github/workflows
schedule:
interval: "weekly"
groups:
actions:
patterns: ["*"] # one PR per week instead of one per action
Review those PRs like code, because they are code. A bump PR that is auto-merged pins a malicious release for you just as fast as a floating tag would pull it in. Look at the upstream diff for anything that touches network calls, credentials, or new nested uses: lines.
Enforce it, don't just recommend it
Since August 2025 the Actions policy at enterprise, org, and repo level has a checkbox that fails any workflow using an action not pinned to a full SHA. The same allow-list accepts ! entries to block a specific action or version outright, which is the fastest way to cut off a compromised action across an org while you work out who used it:
# Settings > Actions > General > Allow select actions and reusable workflows
your-org/*,
aws-actions/configure-aws-credentials@*,
docker/build-push-action@*,
!tj-actions/changed-files@*
Scan first, then enforce. Run a scanner across the org to find unpinned uses, fix them, then turn on the SHA requirement. Turning it on first breaks every unpinned workflow on its next run.
What a SHA pin does not cover
Nested actions inside composite actions
A composite action you pinned by SHA can itself call other actions by tag. You get whatever those tags point to today. When reviewdog/action-setup@v1 was backdoored in March 2025, other reviewdog actions that call it by tag passed the payload on, including to workflows that had pinned those actions by SHA.
An action whose action.yml says `image: docker://some/image:latest`, or whose Dockerfile starts `FROM some/image:tag`, pulls a mutable image on every run.
Things the action downloads at runtime
Setup actions that fetch 'the latest' binary, install scripts piped from curl, and unpinned package installs. The SHA pins the wrapper, not what it fetches.
Reusable workflows
`uses: org/repo/.github/workflows/build.yml@main` is a mutable reference to a whole job, secrets included if you pass `secrets: inherit`.
Impostor commits
GitHub resolves a SHA from any fork in the repository's network, so `owner/action@<sha>` can point at a commit that only exists in an attacker's fork. Check that a new SHA is reachable from a tag or branch in the real repo.
If Dependabot or Renovate PRs for actions merge without review, a malicious release gets pinned for you. Pinning buys review time only if someone uses it.
GitHub's 2026 roadmap targets the first of these directly: a dependencies: section in the workflow file that locks every direct and nested action to a SHA, so composite actions no longer hide what they pull in. Until that is available to you, prefer actions that pin their own dependencies (OpenSSF Scorecard's Pinned-Dependencies check shows this), and vendor small actions into your own org where you can.
If you publish actions yourself
Turn on immutable releases, so a published tag is locked to its commit and can't be deleted or moved.
Add a tag ruleset that blocks force-updates and deletion for everyone, including admins.
Pin every nested uses: and Docker image inside your action by SHA or digest, so your consumers' pins mean something.
Publish from a workflow that runs no untrusted code, with a token scoped to that repository only.
Hardening, layer by layer
Controls that are set once for the whole org beat controls that rely on every workflow author getting it right. Work from the top down. Each line is an item on the Checklist, with the tier of the attack techniques it stops, the effort, and the plan it needs when that is more than Free.
1. Org and enterprise policy
Set once for every repository, so no workflow author has to remember them.
Scan workflow files on every pull request, the same way you scan code, and watch what jobs do while they run. These are the tools on the Tooling page for workflows, pinning and runners, with how each works and how to run it in CI.
The GitHub changes that touch a hardening item above, from the changes to act on. Each one is checked against GitHub's changelog post, and the fix is the checklist item it links.
1 action-required change is coming up. 5 more are already in effect; check you made them.
Kind
Actor and event rules that decide who and which events can start a workflow are generally available for enterprises, organizations and repositories, with rules per workflow file, insights, an evaluate mode and a REST API. Public repositories with no event policy of their own get a default rule that disables pull_request_target. It starts in evaluate mode and GitHub enforces it on 2 December 2026 (moved from 2 November in an editor's note).
Why it matters: A public repository whose workflows rely on pull_request_target stops running them on that date unless an event policy allows it. Most CI/CD compromises start with an outsider triggering a privileged workflow, so the rules are worth setting on purpose, not left to the default.
The default sub claim now carries the owner and repository IDs: repo:ORG@ORG_ID/REPO@REPO_ID:ref:refs/heads/main. Repositories created, renamed or transferred after 15 July 2026 use it. Older ones keep the name-only form until they opt in. GitHub changed the separator from - to @ on 10 June 2026. github.com only.
Why it matters: A trust policy that matches repo:ORG/REPO stops working when a repository moves to the new form, and until then it trusts whoever holds that name, including someone who registers it after a rename or deletion.
pull_request_target takes the workflow file and checkout commit from the default branch, not the pull request's base branch. Environment branch rules are checked against the ref that runs: refs/pull/NUMBER/merge for pull_request events, the default branch for pull_request_target.
Why it matters: An old, vulnerable copy of a workflow on another branch can no longer be started by aiming a pull request at that branch. Environment branch patterns written for the pull request's head may stop matching, and turning environment rules off to fix that exposes their secrets.
The refs REST endpoint stopped accepting POST requests from users and apps that only have permission to read and write packages. Creating a tag or branch now needs contents write: the public_repo scope on a classic PAT, Contents read and write on an app, contents: write in a workflow.
Why it matters: Before this, a token meant only for publishing packages could also create branches and tags in the repository. A release workflow that tags with such a token fails until it asks for contents: write.
Writing ::save-state:: or ::set-output:: to the log is deprecated in favour of the GITHUB_STATE and GITHUB_OUTPUT files. Runners from 2.298.2 warn on it, and actions that use the toolkit need @actions/core 1.10.0 or later. The removal planned for 1 June 2023 was postponed in July 2023 and has no date.
Why it matters: Any untrusted text a step prints, such as a pull request title or a dependency's output, can set a step output or state that later steps trust. The old commands still work, so workflows that use them are still exposed.
From 29 September 2026, a self-hosted runner below 2.329.0 cannot register or reregister, and a runner that has not installed a runner release within 30 days stops getting jobs, even if it was registered before. A critical security release stops jobs until it is installed. Runners with automatic updates on meet this as long as they reach the update service. github.com only; Enterprise Server is not affected.
Why it matters: Runners built from images with updates turned off stop running jobs, and workflows wait in the queue or fail. The 30-day rule also means a runner can no longer run for months without a security fix.
A .github/workflows/actions.lock file, made with the gh actions-lock extension, records the commit of every action a workflow uses, including the actions and reusable workflows those call. Once a workflow is onboarded, every dependency needs an entry and runs use the recorded commit even if a tag or branch moves. Administrators can require lockfiles for an enterprise, organization or repository. Public preview on Free, Team and Enterprise Cloud.
Why it matters: A SHA pin covers only the action you name, not the actions it calls, so a moved tag one level down still changes what runs with your secrets. GitHub notes that locking does not make a dependency safe, so review it before locking it, and review changes to the lockfile like code.
A cache-mode key at the workflow or job level allows read, write, write-only or none. A job's setting overrides the workflow's, and a reusable workflow gets no more than its caller. Without it, low-trust events such as pull_request_target default to read. Declaring write on such an event overrides that default, with a warning annotation.
Why it matters: Release and publish workflows can now be set to none or write-only, so they never restore a cache that something less trusted wrote. Search for cache-mode: write next to pull_request_target, since it undoes the read-only default.
Earlier opt-ins and defaults (8): past their effective date, or older than 90 days
Enterprise audit log streams can include the API requests made against the enterprise's private assets. Requests against public repositories are left out. It has to be turned on in the enterprise's audit log stream settings.
Why it matters: Most audit log events record changes, not reads. API request events show which token read what, which is what you need to see a stolen token cloning or exporting data.
Runs on events that someone other than a collaborator can start, in the default branch's cache scope, get a cache token that can restore but not save. That covers pull_request_target, issue_comment and workflow_run started by a fork's pull request. push, schedule, workflow_dispatch, repository_dispatch and others keep read and write. A blocked save logs a warning and the job goes on.
Why it matters: This closes the TanStack path, where a fork's pull_request_target run wrote a cache that the release workflow restored. It covers only the cache service: artifacts a workflow_run downloads, and files left on a non-ephemeral self-hosted runner, are still untrusted.
actions/checkout v7 fails when a pull_request_target run, or a workflow_run started by a pull request, checks out the head or merge code of a fork's pull request, unless the step sets allow-unsafe-pr-checkout. On 20 July 2026 the check reached every supported major tag, so @v4 and later picked it up. Workflows pinned to a commit SHA or a minor or patch version did not.
Why it matters: This is the usual pwn request: a privileged workflow that builds a fork's code. The guard does not cover git clone or gh pr checkout in a run step, third-party checkout actions, other triggers such as issue_comment, or a SHA pin from before the backport. allow-unsafe-pr-checkout: true turns it off for that step.
Organization and enterprise admins can choose custom properties to include in OIDC tokens. Every repository with that property set then gets a claim prefixed repo_property_, and a property can also go into the subject claim. A settings page for the claims is in public preview at repository, organization and enterprise level.
Why it matters: A cloud trust policy can match a property such as an environment or owning team instead of a list of repository names that has to be kept current. Anyone who can set that property on a repository can then get the role, so restrict who can edit it.
In the allowed actions policy, an entry prefixed with ! blocks that action or version and is evaluated last, over anything that allows it. A new checkbox fails any workflow that uses an action not pinned to a full commit SHA. Both work at enterprise, organization and repository level.
Why it matters: A compromised action can be blocked everywhere at once instead of workflow by workflow, and pinning stops being something each author has to remember.
Code scanning finds script injection, unvalidated inputs and missing permissions in workflow files. Default setup turns it on when a repository has workflows on its default branch; advanced setup adds the actions language. In Enterprise Server from 3.18.
Why it matters: Script injection through a pull request title or branch name is one of the most common ways into a workflow, and this finds it before merge.
New enterprises, new organizations outside an enterprise and new personal repositories get a read-only GITHUB_TOKEN by default. New organizations in an enterprise and new repositories in an organization inherit from their parent. Existing enterprises, organizations and repositories kept their setting.
Why it matters: An organization created before February 2023 still gives every workflow a token that can push code and create releases unless someone changed it. Any step that runs untrusted code can use that token.