ci: pin GitHub Actions to commit SHAs (#5br) - #525
Merged
Conversation
Replace every uses: foo/bar@vN reference with uses: foo/bar@<40-char-sha> # vN in the three workflow files. This prevents a malicious tag overwrite on any action (actions/checkout, dtolnay/rust-toolchain, codecov/codecov-action, gitleaks/gitleaks-action, etc.) from silently injecting code into our CI. Tag comments preserved so reviewers and dependabot can still see the intended major version at a glance.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every
uses: foo/bar@vNreference across the three workflow files is now pinned to a full 40-char commit SHA, with the original tag preserved as a trailing# vNcomment. Borrowed from Zero's rocicorp/mono#5998.Why
GitHub tags are mutable. A compromised maintainer account, a leaked publish token, or a typo-squatted action can silently re-point
v4at malicious code, and our CI would pick it up on the next run with no visible diff. SHAs are immutable: pinning means an attacker who overwrites the tag can't change what our workflows actually execute. The cost is small (lose automatic minor-version updates) and dependabot covers the maintenance gap.If you have dependabot enabled on the repo, add a
.github/dependabot.ymlconfig forpackage-ecosystem: github-actionsso it opens PRs whenever a pinned action publishes a new SHA under its tag. That keeps us patched without giving the supply chain a free hand.What's in the diff
.github/workflows/rust.yml- pinnedactions/checkout@v5,actions/setup-python@v5,taiki-e/install-action@v2,codecov/codecov-action@v6.github/workflows/release.yml- pinnedactions/checkout@v4,dtolnay/rust-toolchain@stable,actions/upload-artifact@v4,actions/download-artifact@v4,actions/setup-node@v4,softprops/action-gh-release@v2,gitleaks/gitleaks-action@v2.github/workflows/sync-next.yml- pinnedactions/checkout@v4,peter-evans/create-pull-request@v612 unique action references resolved via
gh api repos/<owner>/<repo>/git/refs/tags/<tag>(annotated tags followed to their target commit). YAML re-parses cleanly.Test plan
Rust / lintworkflow passes (uses the new pinnedactions/checkout@93cb6e...,actions/setup-python@a26af6...)Rust / skill-validatepassesRust / buildpasses (taiki-e/install-action@65851e...,codecov/codecov-action@e79a69...)Rust / coveragepassesFollow-ups
.github/dependabot.ymlwith agithub-actionsecosystem block so dependabot opens PRs for SHA bumps as new versions land. Tracking separately to keep this PR purely about pinning.