We manage your security to weather the AI storm →

← Resource Hub

GitHub Actions Security Best Practices for Crypto Teams

By Daniel GelfandPublished 6 min read

Part of our guide to Web3 penetration testing

GitHub Actions Security Best Practices for Crypto Teams

Quick answer. Lock dependencies or pin full commit SHAs. Scope tokens and short-lived OIDC credentials per job, isolate untrusted runs on disposable runners, restrict egress, require independent approval for deployment and signing, and keep signing keys outside CI.

Watch: GitHub Actions Security Best Practices for Crypto Teams 1:44
Video transcript

A GitHub Actions job can read secrets, change deployments, or reach a signer. The answer is to lock dependencies, scope every job, isolate untrusted pull requests, and keep signing keys outside CI.

Treat CI as a production trust boundary. A compromised workflow can use the permissions and secrets its job receives, so test jobs should not deploy or sign.

Start with locking dependencies. Use a workflow lockfile where supported, or pin actions and reusable workflows to reviewed full commit SHAs. Then grant least privilege, adding write scopes only to the job that needs them.

For untrusted pull requests, use pull request without secrets or write access. Treat pull request target and workflow run consumers as privileged: never check out or execute contributor code, and validate artifacts as untrusted data.

For cloud access, use OpenID Connect for short-lived credentials, with trust constrained by repository, ref and environment. Put deployment and signing in a protected environment, and keep private keys in KMS, HSM or MPC systems.

Isolate runners from untrusted work. Use fresh just-in-time runners, restrict egress, allow only approved actions, and require CODEOWNERS review for workflow changes.

Before rollout, test a staging baseline. Open a benign fork pull request, verify production role denial, check independent release approval, and rehearse the incident drill.

The full guide shows how to check what a compromised job can reach. Talk to Guardian about an infrastructure pentest.

Why CI Reaches Crypto Keys

A test job should never mint tokens or upgrade a contract. Carry GitHub Actions security best practices into cloud IAM: deny test jobs deploy and signing permissions.

Resolv says a malicious workflow stole credentials in its March 22, 2026 incident. Merge approval blocked deployment through GitHub.[1]

Resolv says the attackers later gained signing authority by changing a cloud key policy. Protect both the release path and the signer.

An infrastructure pentest checks runner permissions, artifact integrity and whether a compromised job can ship code or reach a signer.

Lock and Pin Actions

In March 2025, attackers moved tj-actions/changed-files tags to code that leaked secrets into workflow logs.[2]

Unit 42 identified a March 14, 2025 attack on Coinbase's AgentKit before the wider tj-actions compromise. Coinbase told Unit 42 it found no damage to AgentKit or other Coinbase assets.[3]

A reviewed pin would have kept a moved tag from changing the code that ran. The tj-actions compromise breakdown covers the timeline and exposure checks.[4, 5]

Onboard every workflow you want to protect with gh actions-lock. Review the resolved commits and commit .github/workflows/actions.lock with any workflow changes.[6, 7]

Lockfiles pin transitive action dependencies for onboarded workflows but skip ./ workspace actions. Pin external reusable workflow calls to full commit SHAs and lock dependencies in the defining repository.

Without a lockfile, pin each action to a full commit SHA from upstream, not a fork. Check composite actions for nested references that can move.[8]

Enable Dependabot for GitHub Actions. For each update, inspect the code diff for new downloads, permissions or destinations before accepting the SHA or regenerated lockfile entry.

Pin container images by digest and verify downloaded tools against trusted checksums or signatures. The lockfile covers neither runner images nor runtime downloads.

Restrict the Job Token

Choose Restricted under organization Workflow permissions: read-only contents and packages. In YAML, set permissions: {} or grant contents: read under permissions for checkout.[9, 10]

Unit 42 found that AgentKit's affected changelog job ran with write-all permissions. A job that only reads changed files should not carry a write token.[3]

Grant write access per job. A package publish job might need packages: write; a unit test job should not.

A job permissions block replaces the workflow block, and omitted scopes become none. An action can use github.token even if you never pass it explicitly.[8]

Turn off Actions' ability to create or approve pull requests unless you need it. Never substitute a maintainer's personal token for a missing scope.[11]

Pass named secrets to reusable workflows rather than using secrets: inherit. Keep routine test jobs free of repository and organization secrets.

Isolate Untrusted Pull Requests

Run fork tests on pull_request without secrets or write access, including in private repository settings. Where supported, require maintainer approval for all outside contributors' fork workflows.[9, 11, 12]

Reserve pull_request_target for tasks like labeling; never run or check out contributor code there. Update reviewed actions/checkout pins for GitHub's safer defaults, but keep that rule.[13]

Pass PR titles, branch names and comments as data through action inputs or quoted environment variables. Do not interpolate event fields into shell source.[8]

A workflow_run job can have privileges its upstream run did not. Validate the format of fork artifacts, but never execute or deploy them.

Set cache-mode: none on signing jobs that do not need a cache. Do not share mutable build caches across untrusted and production jobs.[10]

Use execution protections to restrict who can start deploy workflows and which events trigger them. Test the rules in evaluate mode before enforcing them.[14]

GitHub schedules permanent default blocking of pull_request_target for December 2, 2026 in public repositories on Free, Team and Enterprise Cloud unless an applicable event policy explicitly allows it. Private and internal repositories and Enterprise Server are excluded.[15]

Gate Cloud Access and Signing

Replace stored cloud credentials with OpenID Connect (OIDC). Grant id-token: write only to the job that needs a short-lived cloud session.[16, 17]

Match the OIDC audience and exact subject for the repository and environment or ref. Where your provider supports it, bind the production role to the approved release workflow, using job_workflow_ref for reusable workflows.

An environment name replaces the branch in GitHub's default OIDC subject for that job. Restrict the environment to approved branches or tags.[18]

Put deploy and signing jobs in a protected environment. Require a reviewer, prevent self-review and disable administrator bypass where supported.

Free, Pro and Team plans limit required reviewers to public repositories. For private repositories on those plans, put approval in the deployment or signing system.

Verify the artifact digest against trusted build provenance for the approved repository, workflow and commit. For onchain changes, show the chain, target, decoded calldata and simulation result.

Keep private keys in a KMS, HSM or MPC system, not in CI.[19]

In Guardian's public Bounce Tech report, shell tracing could expose a private key in build logs. The Low finding was resolved.[20]

Separate deploy, signing and key administration roles. For automated signatures, scope access to one key and enforce transaction limits at the signer or onchain.

For upgrades and treasury moves, let CI propose and multisig signers verify and approve independently. The smart contract CI/CD guide shows how to build that release step into a Foundry pipeline.[21]

Isolate Runners and Set Policy

Use GitHub-hosted runners for untrusted pull requests. When private networking requires self-hosting, use just-in-time runners on fresh instances with disposable storage.[8]

Limit production runners to approved repositories and, where supported, selected deploy workflows on protected refs. Otherwise restrict access to a dedicated release repository; isolate test runners from cloud metadata, internal services and signers.[22]

Log outbound traffic before enforcing an allowlist at the runner network boundary. Include only registries, cloud APIs and signing endpoints a job needs.

GitHub's hosted-runner firewall is a Linux technical preview. File-based enforcement requires a firewall-enabled runner, job permission contents: read, and a valid .github/egress-firewall.yaml in enforce mode on the running ref.[23]

Allow only approved actions and reusable workflows at the organization level. Require lockfiles where supported.[7, 11]

Locked actions satisfy the full SHA policy. Tag or branch allowlist entries do not match locked dependencies, so allow the reviewed commit SHAs.[4]

Enable Require review from Code Owners in branch protection for release branches. In .github/CODEOWNERS, assign owners to workflows, CODEOWNERS itself, local actions and deploy scripts.[24]

Enable CodeQL workflow scanning where available. Assign owners to investigate unexpected workflow edits, secret changes, runner registrations and changes to cloud signing permissions.

GitHub Actions Hardening Checklist

Start with repositories that can change production or reach a signer. Use one staging repository to verify the organization baseline before rolling it out.

  • Inventory: record each production job's owner, trigger, dependencies, runner group, cloud role and downstream signing or deploy permissions.
  • Dependency policy: open a staging change with an unapproved action and verify that organization policy rejects it.
  • Fork isolation: open a benign fork PR and confirm its tests cannot reach production runners, secrets or cloud roles.
  • Cloud trust: verify that requests from a staging repository and an unapproved ref are denied the production role.
  • Release gate: verify the requester cannot approve their own release and that deployment waits for an eligible independent approver.
  • Runner egress: test that a staging job cannot contact a harmless destination outside its allowlist.
  • Incident drill: identify who can block a compromised action, suspend deployments and revoke credentials. Save workflow run IDs and artifact digests for review.

Check What a Compromised Job Could Reach

Bring the repositories and cloud accounts that can reach production to scope a Guardian infrastructure pentest.

Frequently Asked Questions

How do I block a compromised action across the organization?

Add an explicit block in the organization’s allowed actions policy. A block overrides an allow rule. Block the action at all versions while you investigate, or block the exact affected commit for locked workflows.[11, 25]

Does listing two environment reviewers require two approvals?

No. One eligible reviewer can release the job. If a production change requires a quorum, enforce it separately at the signer or deployment system.[18]

Can renaming a GitHub repository break cloud OIDC login?

Yes. The cloud trust policy must match the new subject. On GitHub.com, renames and transfers after July 15, 2026 also move repositories to the immutable subject format, which includes owner and repository IDs.[17]

Sources

  1. Resolv: Resolv Postmortem: March 22, 2026 Incident
  2. GitHub Advisory Database: tj-actions changed-files through 45.0.7 allows remote attackers to discover secrets by reading actions logs
  3. Palo Alto Networks Unit 42: GitHub Actions Supply Chain Attack: A Targeted Attack on Coinbase Expanded to tj-actions/changed-files
  4. GitHub: Workflow dependency lockfiles
  5. Guardian: The tj-actions/changed-files Compromise Explained
  6. GitHub: Locking action dependencies in a repository's workflows
  7. GitHub Changelog: GitHub Actions workflow lockfiles are generally available
  8. GitHub: Secure use reference
  9. GitHub: Disabling or limiting GitHub Actions for your organization
  10. GitHub: Workflow syntax for GitHub Actions
  11. GitHub: Managing GitHub Actions settings for a repository
  12. GitHub: Securely using pull_request_target
  13. GitHub Changelog: Safer pull_request_target defaults for GitHub Actions checkout
  14. GitHub Changelog: Workflow execution protections in GitHub Actions generally available
  15. GitHub Changelog: pull_request_target blocked by default December 2
  16. GitHub: OpenID Connect
  17. GitHub: OpenID Connect reference
  18. GitHub: Deployments and environments
  19. Guardian: Secrets Management Best Practices for Crypto Companies
  20. Guardian: Bounce Tech, Automation Layer and Contract Updates, finding L-06
  21. Guardian: Smart Contract CI/CD Pipeline: Foundry, Slither and Fuzzing
  22. GitHub: Managing access to self-hosted runners using groups (GitHub Enterprise Cloud)
  23. GitHub: Actions native egress firewall for GitHub-hosted runners
  24. GitHub: About code owners
  25. GitHub Changelog: GitHub Actions policy now supports blocking and SHA pinning actions
  26. GitHub Security Lab: Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests
  27. GitHub Changelog: Immutable releases are now generally available
  28. tj-actions: Releases
  29. Nx: Malicious versions of Nx and supporting plugins were published
  30. Aqua Security: Trivy ecosystem supply chain temporarily compromised
  31. Aqua Security: Update: Ongoing Investigation and Continued Remediation
  32. GitHub: Artifact attestations
  33. GitHub: Using artifact attestations to establish provenance for builds
  34. GitHub: actions/attest-build-provenance
  35. GitHub: actions/attest