Pin Third-Party GitHub Actions to a Commit SHA
Your workflow uses: actions/checkout@v6. That looks like a version number but it’s actually a label and a label is just a pointer that someone else can move. And anyone who gets access to an action’s repo can re-point a tag to a different commit or delete it.
noteQuoting the GitHub docs(opens in new tab) here: “a tag can be moved or deleted if a bad actor gains access to the repository storing the action.” Your workflow file itself doesn’t change in that scenario.
That’s what happened to tj-actions/changed-files earlier this year around March (see GitHub advisory(opens in new tab)). Attackers went back and altered a bunch of version tags to point to a malicious commit. The payload in question exposed CI/CD secrets in the workflow logs.
The fix? Pin to a full-length commit SHA. The docs say that “currently the only way to use an action as an immutable release” is to pin to a SHA. A SHA names a single commit.
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1The SHA is what actually runs. The comment is for the human reading the file. Dependabot will also see it. And I think, if the comment is on the same line as the SHA, then Dependabot will keep the version in it up to date.
To find the SHA for a tag, ask the remote:
git ls-remote https://github.com/actions/checkout 'refs/tags/v6.0.1*'If the tag is annotated the list will also have a line ending in ^{}. That line is the commit. A plain git rev-parse on an annotated tag will return the tag object rather than the commit and that’s a different SHA.
There are two caveats to this. First, get the SHA from the action’s own repo and not a fork. The documentation asks you to confirm that the SHA “is from the action’s repository and not a repository fork”.
Pinning also has a cost. Dependabot won’t be raising alerts for SHA pinned actions so that safety net is gone. Version updates will still open PRs when a new release comes out if you’ve turned them on.
bonusIf you’re an admin of the repo or the organization you can make the pin mandatory. A repo or organization policy can require full length SHAs (GitHub changelog August 2025(opens in new tab)) and any workflow that uses an unpinned action will fail.
So yeah.. pin your github actions.