Lock Down Your GitHub Actions: Supply Chain Security in Practice

Lock GitHub Actions references to commit SHAs to prevent supply chain attacks from moved tags.
The article focuses on GitHub Actions supply chain security, noting that the common `uses: actions/checkout@v4` uses a mutable tag that maintainers or attackers can repoint to a new commit, so a workflow that runs today may execute malicious code tomorrow. It cites Hugo van Kemenade's *Lock Your GitHub Actions*, which recommends replacing tags or branches with the full 40-character commit SHA, using content-addressed immutability as a "cryptographic lock." It also discusses maintenance costs and mitigation options like Dependabot auto-updates, version comments after SHAs, and regular audits. Hacker News discussion shows most agree locking is necessary but low-risk Actions can be weighed against cost; GitHub's official docs now recommend SHA locking for third-party Actions. The article ends with an action checklist covering auditing, replacement, automated updates, and documentation.
Introduction: Why GitHub Actions Need to Be "Locked"

In modern software development, continuous integration and continuous delivery (CI/CD) have become standard practice, and GitHub Actions—thanks to its deep integration with the GitHub ecosystem—has become the preferred automation platform for many open-source projects and enterprises. Yet convenience hides an often-overlooked security risk: the Actions you reference can be tampered with at any time.
Well-known developer Hugo van Kemenade explains in detail how to defend against supply chain attacks by "locking" Action versions in his blog post Lock Your GitHub Actions. The post gained 285 points and 59 comments on Hacker News, showing just how much the community cares about this topic.
The Root of the Problem: Mutable References and Supply Chain Attacks
GitHub Actions workflow files (such as .github/workflows/ci.yml) typically use the uses keyword to reference Actions, for example:
uses: actions/checkout@v4
Here, v4 is a tag, not a fixed version. The problem is that tags can be moved or repointed. The Action's maintainer (or an attacker) can point the v4 tag at a new commit at any time, which means the workflow you run today may execute completely different code tomorrow.
This mechanism provides fertile ground for supply chain attacks. Once a popular Action's repository is compromised, an attacker can push malicious code to the location the tag references, and every workflow using that tag will automatically pull and execute the malicious script—stealing secrets, tampering with code, or planting backdoors.
The nature of Git references (refs): Branches and tags in Git are both "mutable pointers" to a commit object. Tags come in lightweight and annotated forms, but either way, git tag -f or pushing a new tag can make a tag of the same name point to a different commit, and by default this doesn't trigger a warning on pull. In GitHub Actions' uses: owner/repo@ref syntax, ref can be a branch, a tag, or a full SHA; the first two are resolved by GitHub to the latest commit at the time of each run, so they offer no content integrity guarantee. Only the 40-character (SHA-1) or 64-character (SHA-256) commit hash is content-addressed—any rewrite of history changes the hash, providing cryptographic immutability. This is exactly the technical basis on which SHA locking defends against supply chain attacks.
The Solution: Commit SHA Locking
The core recommendation Hugo van Kemenade makes is straightforward: use the full commit SHA instead of a tag or branch reference.
uses: actions/checkout@a1b2c3d4e5f6... # full 40-character SHA
A commit SHA is content-addressed and tamper-proof. Once a SHA is specified, GitHub pulls exactly that commit, regardless of how tags change afterward. It's effectively a "cryptographic lock" on your workflow.
Trade-offs in Implementation
Locking SHAs is not without cost. Every time an Action needs to be upgraded, developers must manually find and replace the SHA, which adds maintenance burden. The community has proposed several ways to mitigate this:
- Use dependency management tools: Tools like Dependabot can automatically create PRs to update SHA versions.
- Combine with version comments: Add a comment after the SHA noting the corresponding version number for easier human readability.
- Audit regularly: Make SHA locking part of the security review process to ensure timely updates.
Dependabot's support for GitHub Actions: Dependabot natively supports the github-actions ecosystem—it parses uses references in workflows and automatically creates PRs when upstream publishes new version tags. When the reference is in the format owner/repo@<SHA> # vX.Y.Z, Dependabot can recognize the version number in the comment, update the SHA to the commit corresponding to the new version, and preserve the readable comment. Renovate offers similar capabilities and supports more granular grouping and scheduling strategies. Note that automated update PRs are themselves part of the supply chain: before merging, review the changed Action's publisher, changelog, and permission scope, so automation tools don't bring malicious updates directly into the main branch.
Community Discussion and Multiple Perspectives
In the Hacker News discussion, developers shared their own practical experiences. Most comments agreed on the necessity of SHA locking, but some pointed out that for personal projects or infrequently used Actions, the cost of maintaining SHAs may outweigh the risk.
One middle-ground view: strictly lock SHAs for high-privilege Actions (such as those involving deployment or secret management), while lower-risk auxiliary tools can be relaxed to tags. However, security experts generally agree that with supply chain attacks becoming increasingly frequent, adopting SHA locking by default is the safer strategy.
Additionally, some comments noted that GitHub's official documentation has begun recommending SHA locking for third-party Actions, reflecting the platform's guidance toward security best practices.
Least privilege and the workflow permission model: SHA locking solves the "immutable reference" problem, but it cannot limit an Action's runtime capabilities. The default permissions of GitHub Actions' GITHUB_TOKEN can be set to read-only at the repository or organization level, and workflows can explicitly narrow them via a top-level permissions: field (for example, granting only contents: read). For jobs involving deployment or secrets, it's recommended to combine environment protection rules, required approvals, and OIDC federated identity to replace long-lived cloud credentials. Only by layering SHA locking on top of the principle of least privilege can you achieve defense in depth—locking alone cannot stop an already-authorized Action that is itself malicious from accessing resources within its permission scope.
How to Get Started: Action Checklist
If you want to immediately improve the security of your workflows, follow these steps:
- Audit existing workflows: List all
usesstatements in your.github/workflows/files and flag those that use tags or branch references. - Replace with SHAs: Get the full SHA of the latest stable version via the GitHub API or by directly viewing the Action repository's commit history.
- Configure automated updates: Enable Dependabot or Renovate to automatically create PRs for Action updates (with SHA changes included).
- Document the convention: Establish clear security standards for Action references within your team and add them to the code review checklist.
Conclusion
Lock Your GitHub Actions is short but hits the key pain point of CI/CD security. With software supply chain attacks intensifying, changing Action references from mutable tags to immutable SHAs is a low-cost, high-reward security hardening measure. As the HN discussion reflects, a community consensus is forming: lock your Actions—don't leave a backdoor for attackers.
Related articles

Zed Editor Releases v1.29.2: Observations on a Routine Version Iteration
Zed editor releases patch v1.29.2, version bump by @JosephTLyons, commit verified via GitHub signature. This article covers the release's basic info, what a patch version means, and practical upgrade advice for users.

Anthropic IPO Questioned: Hacker News Debates Timing of Going Public
A Hacker News post titled "Just say no to Anthropic's IPO" sparks debate on the timing of Anthropic's public listing and AI capitalization, touching on valuation bubbles and mission independence.

Hands-On with the Genie 4 World Model: Directing Worlds in Real Time Like a Puppeteer
Google DeepMind's Genie 4 world model in depth: Special Guest X's hands-on demo of real-time scene direction via prompts, custom interactive apps in Project Genie, and prompts-as-seeds reproducibility.