Skip to content

Pin CI actions to commit SHAs - #112

Merged
tobi merged 1 commit into
tobi:mainfrom
bostonaholic:pin-ci-actions
Nov 25, 2026
Merged

tobi merged 1 commit into
tobi:mainfrom
bostonaholic:pin-ci-actions

Conversation

@bostonaholic

Copy link
Copy Markdown
Contributor

Why

Tags and branches can be moved. Anyone who controls an action's repository, including someone who has compromised it, can point @v5 or @master at different code, and every workflow that uses that ref runs the new code on its next run. A full commit SHA can't be moved that way.

This matters most for release.yml. It runs with permissions: contents: write and gets MACOS_CERTIFICATE, MACOS_CERTIFICATE_PASSWORD, NOTARY_KEY_P8 and the other signing secrets. If one of the three actions it uses were compromised, the injected code could steal those secrets or tamper with the published release.

This has happened before. In March 2025 the tj-actions/changed-files tags were rewritten to point at a commit that dumped CI secrets into workflow logs, across thousands of repositories (CVE-2025-30066). Workflows pinned to a SHA were not affected.

References

What

Each action is pinned to the commit its current ref resolves to today, so nothing in the behavior changes. A trailing comment records the ref it replaced.

Action Was Now
actions/checkout @v5 @fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
dtolnay/rust-toolchain @master @683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
Swatinem/rust-cache @v2 @d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3

I got the SHAs from the GitHub API. v5 and v5.1.0 resolve to the same commit. v2 and v2.9.3 are annotated tags, and both dereference to the commit pinned here. dtolnay/rust-toolchain is pinned to the current head of master. The workflows already pass toolchain: "1.97", so pinning the action doesn't change which Rust gets installed.

Trade-off

Pinned actions don't update on their own. If you want, a Dependabot config with package-ecosystem: github-actions would open bump PRs and keep the # vX.Y.Z comments up to date. I left it out to keep this change small.

Test plan

  • Both workflow files parse as YAML
  • Every uses: line is pinned (8 checkout, 7 rust-toolchain, 7 rust-cache)
  • CI on this PR is green on Linux, macOS and Windows

🤖 Generated with Claude Code

https://claude.ai/code/session_012Gk1HsqV3Fp5JVGKdfq3sm

A tag or branch can be moved to new code at any time; a commit SHA
cannot. The release workflow holds contents: write and the signing and
notarization secrets, so whatever code those refs point to at run time
can publish a release. Each pin keeps the ref it replaced as a comment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Gk1HsqV3Fp5JVGKdfq3sm
huntharo added a commit to pwrdrvr/PwrDisk that referenced this pull request Oct 31, 2026
* Pin CI actions to commit SHAs

A tag or branch can be moved to new code at any time; a commit SHA
cannot. The release workflow holds contents: write and the signing and
notarization secrets, so whatever code those refs point to at run time
can publish a release. Each pin keeps the ref it replaced as a comment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Gk1HsqV3Fp5JVGKdfq3sm
(cherry picked from commit 49099bc)

* chore(ci): update pinned action versions

---------

Co-authored-by: Matthew Boston <matthew@matthewboston.com>
@tobi
tobi merged commit 7dd1894 into tobi:main Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants