Filed underL02 · Security
Published
Reading time21 min
Updated
Field notes · L02 Security

Hardening GitHub ActionsOIDC to AWS, pinned SHAs and the lessons from the tj-actions compromise

GitHub Actions hardening for AWS teams: OIDC trust policies with sub conditions, least-privilege tokens, SHA pinning, pull_request_target and runners.

The short answer

To harden GitHub Actions, do five things. Replace stored cloud keys with OIDC federation, and make the AWS trust policy check the sub claim plus GitHub's immutable repository and owner IDs. Set the default GITHUB_TOKEN to read-only and grant each job only what it needs. Pin every third-party action to a full commit SHA, let Dependabot move those pins, and turn on GitHub's SHA-pinning policy. Treat pull_request_target and self-hosted runners on public repositories as off by default. The March 2025 tj-actions/changed-files compromise hit every one of these weak points, and repositories that had done all five were unaffected.

The rest of this post covers how to do each one properly, where each one fails, and a read-only audit you can run across a whole organisation this afternoon.

01What actually happened in the tj-actions/changed-files compromise

Most write-ups start and finish at "an action got backdoored". The full chain is more useful, because each step is a different control that failed.

Date (UTC) Event Control that would have stopped it
2024-11-28 A SpotBugs maintainer adds a personal access token (PAT) to a workflow in spotbugs/sonar-findbugs. Use a GitHub App token or OIDC, not a long-lived PAT
2024-12-06 An attacker opens a pull request that changes the repo's mvnw file. A pull_request_target workflow runs it with secrets, and the PAT leaks. No pull_request_target that runs PR code
2025-03-11 With the SpotBugs PAT, the attacker steals a reviewdog maintainer's PAT and repoints reviewdog/action-setup@v1 to a malicious commit (CVE-2025-30154). Tag protection and immutable releases on the publisher's side
2025-03-14 15:10 coinbase/agentkit, the original target, runs the poisoned tj-actions/changed-files. SHA pinning on the consumer side
2025-03-14 16:57 The attacker rewrites the version tags of tj-actions/changed-files to point at commit 0e58ed8. More than 23,000 repositories use the action. SHA pinning; egress monitoring
2025-03-15 GitHub publishes CVE-2025-30066. The fix ships in v46.0.1. –

Sources: Palo Alto Networks Unit 42, the GitHub advisory, BleepingComputer.

The tj-actions payload downloaded a Python script from gist.githubusercontent.com. The script read the memory of the Runner.Worker process and printed the secrets it found into the workflow log, base64-encoded. On a public repository, anyone can read that log. BleepingComputer reports that secrets were confirmed exposed in 218 repositories. StepSecurity caught it because its runner agent flagged an unexpected outbound call to that gist host.

Four lessons are worth keeping:

  1. Git tags are mutable. @v45 means "whatever the maintainer, or whoever holds their token, points it at today".
  2. Pinning only protects the layer you pin. A composite action pinned by SHA can still pull some/other-action@v1 inside itself. The attacker reached tj-actions through reviewdog/action-setup@v1, which was nested inside another tj-actions action. The reviewdog advisory says it plainly: other reviewdog actions that call action-setup@v1 were compromised "regardless of version or pinning method".
  3. pull_request_target was the way in. The whole chain began with a privileged workflow running code from an untrusted pull request.
  4. Long-lived tokens let the attacker move sideways. Each hop was a PAT. None was an OIDC token scoped to a single job.

02Replace stored AWS keys with OIDC, and write the trust policy properly

With OIDC, each job asks GitHub for a signed JWT. AWS STS checks the token against the IAM OIDC provider for token.actions.githubusercontent.com and returns credentials that last an hour by default. No secret is stored, so there is nothing to steal from the secrets store or to leave behind when someone leaves.

Diagram
┌──────────── GitHub-hosted runner (one job) ─────────────┐
│ permissions: id-token: write                            │
│  1. Request a JWT from the Actions OIDC endpoint        │
│     (aud=sts.amazonaws.com, sub=repo:acme/api:env:prod) │
│  2. Call sts:AssumeRoleWithWebIdentity(role, JWT)       │
└────────────────────────────┬────────────────────────────┘
                             │ JWT                  ▲
                             ▼                      │ session creds
┌──────────────────────── AWS STS ────────────────────────┐
│  3. Verify the signature (IAM OIDC provider), evaluate  │
│     the trust policy Conditions, issue session creds    │
└─────────────────────────────────────────────────────────┘
  4. Short-lived creds sit in the job env and are gone
     when the job ends

OIDC is only as strong as the conditions in the trust policy. In 2023, researchers found roles that checked aud but not sub. Any repository on GitHub could assume them. Wiz has a good write-up. AWS has since closed the worst version of this. IAM now rejects any create or update of a GitHub-trusting policy when token.actions.githubusercontent.com:sub is missing, or when its value is only a wildcard. The check runs only when a policy is created or updated, so policies written before the guardrail still stand as they were. Audit them.

The trust policy we'd actually ship

AWS now exposes most GitHub claims as condition keys: repository_id, repository_owner_id, job_workflow_ref, environment, ref, actor_id and enterprise_id (AWS condition key reference). Use them. Here is a production deploy role for one service:

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "GitHubActionsProdDeploy",
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
          "token.actions.githubusercontent.com:sub": "repo:acme/payments-api:environment:production",
          "token.actions.githubusercontent.com:repository_owner_id": "987654321",
          "token.actions.githubusercontent.com:repository_id": "812345678",
          "token.actions.githubusercontent.com:ref": "refs/heads/main"
        }
      }
    }
  ]
}

The account, owner and repository IDs here are placeholders. Substitute your own.

What each line does:

  • sub with environment:production. When a job declares environment:, GitHub's default subject is repo:ORG/REPO:environment:NAME (GitHub OIDC reference). This ties the role to a GitHub environment. You can put required reviewers, deployment branch rules and wait timers on that environment, which a branch name alone can't give you.
  • repository_owner_id and repository_id. Names can change and can be reused. If someone renames or deletes acme/payments-api, another account can register the name and get a matching sub. The numeric IDs never change. AWS's own documentation now recommends matching on them. Look them up with gh api repos/acme/payments-api --jq '{id, owner_id: .owner.id}'.
  • ref. This is defence in depth. It makes sure the environment job really ran from main, even if someone loosens the environment's branch rules later.
  • StringEquals, not StringLike. Use a wildcard only when you can say exactly which identities it matches.

GitHub is also moving the default sub to include immutable IDs. Repositories created, renamed or transferred after 15 July 2026 get a subject like repo:acme@123456/payments-api@456789:environment:production. Existing repositories keep the old format unless you opt in (changelog). In practice, a trust policy that hard-codes the old sub will stop matching for a new or renamed repository. If you match on repository_id and repository_owner_id as above, you can switch sub formats without losing that protection.

Centralise deploy logic with job_workflow_ref

If you run a platform team, go one step further. Put deployment in a reusable workflow in a locked-down repository. Then require job_workflow_ref in the trust policy:

json
"StringEquals": {
  "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
  "token.actions.githubusercontent.com:repository_owner_id": "987654321",
  "token.actions.githubusercontent.com:job_workflow_ref": "acme/platform-workflows/.github/workflows/deploy-ecs.yml@refs/heads/main"
},
"StringLike": {
  "token.actions.githubusercontent.com:sub": "repo:acme/*:environment:production"
}

Now a product repository can deploy only by calling your reviewed workflow. A step someone adds to their own YAML can't assume the role. This is the right pattern when you have more than a handful of services. It is overkill for three repositories and one AWS account.

The workflow side

yaml
name: deploy
on:
  push:
    branches: [main]

permissions: {}            # nothing by default; grant per job

concurrency:
  group: deploy-production
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-24.04
    environment: production
    permissions:
      contents: read
      id-token: write      # required to request the OIDC JWT
    steps:
      - uses: step-security/harden-runner@351661ca32ac09a36dc5ee2d536e3128f2a3c8ed # v2.22.0
        with:
          egress-policy: audit
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
        with:
          role-to-assume: arn:aws:iam::111122223333:role/gha-payments-api-prod-deploy
          aws-region: eu-west-2
          role-session-name: gha-${{ github.run_id }}-${{ github.run_attempt }}
      - run: ./scripts/deploy.sh

The SHAs above were the release commits on the day of writing. Check them yourself, as described below, before you copy them. role-session-name puts the run ID into every CloudTrail event, which makes incident response much faster.

The provider itself is one Terraform resource:

hcl
resource "aws_iam_openid_connect_provider" "github" {
  url            = "https://token.actions.githubusercontent.com"
  client_id_list = ["sts.amazonaws.com"]
  # thumbprint_list omitted: AWS validates GitHub's certificate chain
  # against its trusted CA store for this provider.
}

thumbprint_list is optional in current versions of the AWS provider (resource docs).

OIDC trust policy failure modes

Mistake What it allows Fix
sub = repo:acme/* Any branch, any workflow, any PR-triggered run in any repository in the org One role per repository and environment, or job_workflow_ref
sub = repo:acme/api:* Feature branches and pull_request runs can assume a production role Match on environment:production and protect the environment
sub = repo:acme/api:pull_request on a write role Any PR-triggered workflow run can get write credentials Give PR roles read-only, plan-only permissions
Name-only matching Takeover if the repository is renamed or deleted and the name re-registered Add repository_id and repository_owner_id
One role for build and deploy A compromised test step gets deploy permissions Separate roles, separate jobs, separate environments
Broad permissions policy OIDC limits who gets credentials, not what they can do Scope the permissions policy; add a permissions boundary

03Lock down GITHUB_TOKEN permissions

Every job gets a GITHUB_TOKEN. Organisations, enterprises and repositories created since February 2023 default to read-only (changelog). Older ones often still default to read/write on everything, and nobody has looked since. Check yours:

bash
gh api orgs/acme/actions/permissions/workflow
# {"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}

Set the organisation default to read and turn off "Allow GitHub Actions to create and approve pull requests" unless you rely on it. Then do this in every workflow file:

  • Put permissions: {} at the top level, so a job you add later starts with nothing.
  • Grant permissions per job, and only the ones that job uses. contents: read to check out code. id-token: write for OIDC. packages: write only in the job that pushes images. pull-requests: write only in the job that comments.
  • Use persist-credentials: false on actions/checkout unless a later step needs to push. If you leave it on, the token stays on disk in .git/config for every later step, including third-party ones.

Least privilege doesn't stop a malicious action from reading secrets the job already has. It limits what a stolen token can do. If tj-actions had stolen a read-only token from a job with no other secrets, it would have got almost nothing.

04Pin actions to full commit SHAs, and keep the pins moving

Here are the options, from weakest to strongest:

Reference style Example Who can change what runs Verdict
Branch @main Anyone who can push to the action's default branch Never
Major tag @v4 Anyone who can move a tag Not for third-party actions
Exact tag @v4.2.1 Same as above; tags can be force-moved Not for third-party actions
Full SHA @3d3c42e5…b1 # v7.0.1 Nobody; a SHA names fixed content Default for everything
Immutable release Tag protected by the publisher's immutable releases setting Nobody, if the publisher turned it on Good, but you depend on the publisher's setting
Workflow dependency lock dependencies: block, including nested actions Nobody, including for transitive actions Announced on GitHub's 2026 roadmap in March 2026; not yet released at the time of writing. Adopt when it reaches your plan

Two details matter more than the decision to pin.

Check that the SHA belongs to the upstream repository. GitHub serves commits from forks through the parent repository's namespace. So owner/action@<sha> can resolve to a commit that exists only in an attacker's fork. Unit 42 describes the tj-actions attacker using forks to stage commits for exactly this reason. Take SHAs from the upstream tag, not from a PR description:

bash
git ls-remote --tags https://github.com/aws-actions/configure-aws-credentials.git 'refs/tags/v6.3.0*'
# e1253824e5c10ff9df46874f81ed3ec929e19cfd  refs/tags/v6.3.0
# For annotated tags, use the ^{} line: that's the commit, not the tag object.

zizmor has an impostor-commit audit that runs this check for you.

Pinning without updates goes stale. Pinned SHAs don't receive security fixes. Let Dependabot raise the PRs. It updates both the SHA and the trailing # vX.Y.Z comment:

yaml
# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: github-actions
    directories: ["/", "/.github/actions/*"]   # include local composite actions
    schedule:
      interval: weekly
    cooldown:
      default-days: 7
    groups:
      github-actions:
        patterns: ["*"]

Dependabot now waits three days by default after a release before opening a version-update PR. Security updates are not delayed. We raise that to seven days for actions. The tj-actions tags were poisoned for under a day. With a cooldown, the poisoned commit would very likely have been flagged and pulled before Dependabot proposed it. A cooldown is a cheap delay that buys time. It is no substitute for reviewing what you merge.

Then enforce it. Since August 2025, the allowed-actions policy can require full SHAs and block specific actions, at organisation or repository level. A workflow with an unpinned action fails. The !owner/action@ref blocklist is your kill switch for the next tj-actions: one org setting stops it everywhere, without a PR to every repository. Check the current state with:

bash
gh api orgs/acme/actions/permissions --jq '{allowed_actions, sha_pinning_required}'

Pinning, Dependabot and the policy still don't cover nested references inside composite actions. To close that gap: prefer actions with no nested uses:, vendor small actions into your own org, and read action.yml before you approve a new action.

05Why pull_request_target is dangerous, and what to use instead

pull_request_target runs on pull requests, including PRs from forks. The workflow file and the token come from the base repository. So the job gets secrets and a token that can write. That is safe only if the job never runs, builds or interpolates anything the PR author controls. The trouble starts when someone adds actions/checkout with ref: ${{ github.event.pull_request.head.sha }} and then runs npm install, a build script, or mvnw. That is exactly how SpotBugs was compromised. Ultralytics was hit in December 2024 by a variant: a branch name was interpolated into a shell step.

GitHub has made two changes here:

  • Since 8 December 2025, pull_request_target always runs the workflow from the default branch. Fixing the workflow on main now actually fixes it. Environment branch rules are now checked against the ref the job runs on, not the PR head.
  • With workflow execution protections, generally available since September 2026, organisations can set rules for which actors and events may trigger workflows. For public repositories with no event policy of their own, GitHub has added a default rule that disables pull_request_target. It runs in evaluate mode for now. GitHub will start enforcing it automatically on 2 November 2026 for affected repositories. If you rely on the trigger, check the evaluation results now.

Our position: you probably don't need pull_request_target. The common reasons for it are labelling, commenting and posting coverage. Here is the split we use instead:

yaml
# .github/workflows/pr-build.yml  (untrusted: no secrets, read-only token)
on: pull_request
permissions: { contents: read }
jobs:
  build:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with: { persist-credentials: false }
      - run: make test coverage.json
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with: { name: coverage, path: coverage.json }
yaml
# .github/workflows/pr-report.yml  (privileged: never executes PR content)
on:
  workflow_run:
    workflows: [pr-build]
    types: [completed]
permissions: {}
jobs:
  comment:
    runs-on: ubuntu-24.04
    permissions: { pull-requests: write, actions: read }
    steps:
      # Download the artifact via the API, parse it as data (jq), validate
      # schema and size, then post the comment. Never run, source or `eval` it.
      - run: ./scripts/post-coverage-comment.sh
        env:
          GH_TOKEN: ${{ github.token }}
          RUN_ID: ${{ github.event.workflow_run.id }}

The privileged half handles only data. Treat the artifact as hostile input: an attacker can upload anything, including a crafted coverage.json built to break a sloppy parser.

Template injection: the same bug without the dangerous trigger

Any ${{ }} expression inside run: is pasted into the script text before the shell sees it. So this is a shell injection:

yaml
- run: echo "Title: ${{ github.event.pull_request.title }}"     # vulnerable

Pass untrusted values through the environment instead. The shell then treats them as data:

yaml
- run: echo "Title: $PR_TITLE"
  env:
    PR_TITLE: ${{ github.event.pull_request.title }}

Treat titles, bodies, branch names, commit messages, issue comments and review comments as attacker-controlled. The same text is just as hostile when an AI agent in your pipeline reads it, which is the problem of prompt injection and least privilege for AI agents. actionlint and zizmor both flag this pattern. Run one of them in CI on the .github/ directory.

06Self-hosted runner risks

Self-hosted runners are where an Actions compromise turns into a network compromise. GitHub's guidance has said for years that self-hosted runners should almost never serve public repositories. Researchers showed why at scale in 2024. Starting from a fork PR, they reached PyTorch's non-ephemeral self-hosted runners and kept access. The Shai-Hulud 2.0 npm worm in November 2025 went the other way. It registered infected developer machines as self-hosted runners called SHA1HULUD and used a workflow triggered by GitHub Discussions as a command channel.

If you need self-hosted runners (GPUs, private network access, data residency, cost at very high volume), apply these rules:

Risk Control
Persistence between jobs Ephemeral runners only (--ephemeral, or Actions Runner Controller / scale sets): one job, then destroy the VM or pod
Jobs inherit the host's cloud identity No instance profile on runner hosts. On EC2, a non-container job runs on the host, and IMDS hop limits won't stop it. Jobs get cloud access through OIDC, like hosted runners
Runner reachable from untrusted code Never attach self-hosted runners to public repositories; restrict runner groups to named private repositories
Lateral movement on the network Put runners in their own subnet with egress allow-lists; no route to production data stores unless that runner group is the deploy path
Rogue runner registration Alert on new runner registrations (audit log events org.register_self_hosted_runner, repo.register_self_hosted_runner and the JIT equivalents *.configure_self_hosted_jit_runner; see GitHub's audit log event list); restrict who can add runners
Long-lived registration tokens Use JIT runner configuration through the API, not a static token in your AMI

For most teams, GitHub-hosted runners, or larger hosted runners with Azure private networking, are the better default. The VM is thrown away after every job. That alone removes the biggest risk.

07Detect what you didn't prevent

Prevention will miss something eventually. In the tj-actions case, the first detection was an outbound network call from a job that had never made one before. Two cheap controls:

  • Egress monitoring on the runner. StepSecurity's harden-runner in audit mode records every outbound destination per job. After a few weeks of baseline, switch the deploy workflows to block with an explicit allow-list, the same egress discipline we apply when sandboxing AI agents that run code. GitHub has a native Layer 7 egress firewall for hosted runners on its 2026 roadmap. Until it ships, use the third-party option.
  • CloudTrail on your OIDC roles. Alert on AssumeRoleWithWebIdentity for a production role outside known deploy windows, from an unexpected role-session-name pattern, or followed by API calls the deploy never makes (iam:*, sts:GetFederationToken, secretsmanager:ListSecrets).

GitHub now also holds some likely-malicious workflow runs for approval on public repositories, which helps against worms like Shai-Hulud. It does nothing for private repositories, so don't plan around it.

08The GitHub Actions hardening audit (reference checklist)

This is the asset to keep. It lists each check, where to look, and what good looks like, in order of importance. Most of it can be verified from the CLI.

# Check How to verify Pass condition Severity
1 No long-lived cloud keys in Actions secrets gh secret list --org acme; grep for AWS_SECRET_ACCESS_KEY None; OIDC everywhere Critical
2 Every GitHub OIDC trust policy has a specific sub Script over aws iam list-roles (below) No repo:org/* or :* on write roles Critical
3 Trust policies match immutable IDs Same script repository_id and repository_owner_id present High
4 Org default token is read-only gh api orgs/ORG/actions/permissions/workflow "read", approve-PRs false Critical
5 SHA pinning enforced gh api orgs/ORG/actions/permissions sha_pinning_required: true High
6 Allowed actions restricted Same endpoint allowed_actions: selected High
7 No pull_request_target that checks out or runs PR code Audit script; zizmor dangerous-triggers Zero, or reviewed and documented Critical
8 No ${{ github.event.* }} inside run: actionlint / zizmor template-injection Zero findings High
9 Every workflow sets top-level permissions Audit script 100% of files Medium
10 persist-credentials: false on checkout zizmor artipacked All except jobs that push Medium
11 Dependabot covers github-actions with a cooldown Check .github/dependabot.yml Present in every active repo Medium
12 Production deploys gated by an environment Repo settings → Environments Required reviewers + branch rule main High
13 Fork PR approval required gh api orgs/ORG/actions/permissions/fork-pr-contributor-approval all_external_contributors for sensitive repos Medium
14 No self-hosted runners on public repos Runner groups → repository access None Critical
15 Self-hosted runners are ephemeral with no instance role Infra code review --ephemeral/ARC; no IAM instance profile Critical
16 No PATs used by workflows Grep for secrets.*PAT*, secrets.*TOKEN* GitHub App tokens or GITHUB_TOKEN only High
17 Egress visibility on deploy jobs Workflow review harden-runner audit/block or equivalent Medium
18 CloudTrail alerting on OIDC role use SIEM rules Alerts on off-pattern AssumeRoleWithWebIdentity Medium
19 Execution protection rules reviewed Org settings → Actions → execution protections Event/actor rules set; evaluate-mode results checked before 2 Nov 2026 Medium
20 Kill-switch drill done Tabletop Team can block an action org-wide and rotate secrets in < 1 hour Medium

A read-only audit script

This sweeps every non-archived repository in an organisation for the workflow-level checks (5, 6, 7, 9, plus unpinned actions). It needs gh authenticated with read access. It changes nothing.

bash
#!/usr/bin/env bash
# gha-audit.sh ORG — read-only GitHub Actions hardening inventory
set -euo pipefail
org="${1:?usage: gha-audit.sh ORG}"

echo "== Org policy"
gh api "orgs/$org/actions/permissions" --jq '{allowed_actions, sha_pinning_required}'
gh api "orgs/$org/actions/permissions/workflow"
gh api "orgs/$org/actions/permissions/fork-pr-contributor-approval" --jq '.approval_policy' || true

echo "== Per-repository findings"
gh repo list "$org" --limit 2000 --no-archived --json nameWithOwner --jq '.[].nameWithOwner' |
while read -r repo; do
  tmp="$(mktemp -d)"
  if gh repo clone "$repo" "$tmp" -- --depth 1 --quiet 2>/dev/null && [ -d "$tmp/.github/workflows" ]; then
    wf="$tmp/.github/workflows"
    # third-party uses: not pinned to a 40-char SHA (local and docker refs excluded)
    grep -RnoE 'uses:[[:space:]]*[^[:space:]#]+' "$wf" \
      | grep -vE 'uses:[[:space:]]*(\./|docker://)' \
      | grep -vE '@[0-9a-f]{40}$' \
      | sed "s|$tmp|$repo [unpinned]|" || true
    grep -RlE 'pull_request_target' "$wf" | sed "s|$tmp|$repo [pull_request_target]|" || true
    grep -RLE '^permissions:' "$wf" | sed "s|$tmp|$repo [no top-level permissions]|" || true
  fi
  rm -rf "$tmp"
done

And for the AWS side (checks 2 and 3), list every role that trusts GitHub and print its conditions:

bash
aws iam list-roles --query 'Roles[].RoleName' --output text | tr '\t' '\n' |
while read -r role; do
  aws iam get-role --role-name "$role" --query 'Role.AssumeRolePolicyDocument' --output json |
  jq -c --arg r "$role" '
    .Statement[]
    | select((.Principal.Federated // "") | tostring | test("token.actions.githubusercontent.com"))
    | {role: $r, cond: .Condition}'
done

Sort the output by hand. Anything with a StringLike on sub that ends in *, or with no repository_id, goes on the fix list. Run zizmor (zizmor .github/) in CI on each repository for the deeper checks the grep can't do.

09Where this crosses into the rest of the stack

CI/CD security doesn't stay inside Security. The trust policy belongs to the Cloud & DevOps layer: whoever designs your AWS account structure decides whether one stolen deploy role reaches one service or everything. PAT hygiene is an identity question for Managed IT. Every PAT belongs to a person, whose account should sign in with phishing-resistant passkeys, and when that person leaves or their laptop is compromised, the PAT goes with them. Many pipelines also hold warehouse or production database credentials, so a CI breach is a Data incident too. The tj-actions chain moved from a static-analysis tool to a code-review bot to a file-diff action to a crypto exchange. No single team owned all of those links. That is exactly why the gaps were there. And hardening the workflow is only half of CI supply-chain security: the other half is proving what it built, with SLSA provenance, SBOMs and Sigstore signing.

10FAQ

Is pinning to a SHA enough on its own?

No. It stops tag rewriting for the action you pin, which would have been enough for the March 2025 tj-actions tags. It does not pin actions nested inside composite actions, it does not protect against a fork commit served under the upstream name, and it goes stale without Dependabot. Pin, check the SHA against upstream, automate updates with a cooldown, and enforce with the org policy.

Should we use a GitHub App token or a PAT for cross-repository automation?

A GitHub App installation token. It is scoped to chosen repositories and permissions, expires after an hour, and doesn't depend on a person staying at the company. Generate it inside the job with actions/create-github-app-token, pinned by SHA. Keep the app's private key in an environment that only the jobs needing it can access. If you run coding agents against your repositories, give them the same scoped tokens; rolling out coding agents across a team covers the wider permission policy.

Do fork pull requests get OIDC tokens?

No. A pull_request run from a fork gets a read-only GITHUB_TOKEN, no repository secrets, and no id-token: write, even if the workflow asks for it. That is why PyPI Trusted Publishing cannot run from fork PRs. Don't rely on that alone. Never grant a write role to a sub ending in :pull_request, and keep deploy roles bound to a protected environment.

We have hundreds of workflows. Where do we start?

Start with org-level settings, because each one fixes every repository at once. Read-only default token. Allowed actions restricted. SHA pinning required, after running the audit script and letting Dependabot or a bulk PR tool pin everything. Execution protection rules. Next, move cloud credentials to OIDC, production deploys first. Then work through pull_request_target findings. Template-injection lint comes last because it's the most widespread and the easiest to automate.

Is GitHub-hosted or self-hosted safer?

GitHub-hosted, for most teams. Each job gets a fresh VM, which rules out the persistence attacks that made the PyTorch research so damaging. Self-hosted is reasonable for private repositories when you need GPUs, private networking or residency. Then it has to be ephemeral, isolated on the network, and free of ambient cloud credentials.

Block it org-wide with a !owner/action entry in the allowed-actions policy. Search workflow runs since the compromise window for any run that used it. Read those logs for leaked material, which in the tj-actions case meant decoding base64 blobs. Rotate every secret those jobs could reach, even where nothing obvious leaked. With OIDC, the credentials you'd otherwise rotate have already expired. That is the strongest argument for moving to it.

If this is the layer that hurts, we should talk.

Tell us which layer hurts →