Repository navigation
ci: Pin actions to commit SHAs and drop the release write permission - #102
Closed
igor-alexandrov wants to merge 2 commits into
Closed
igor-alexandrov wants to merge 2 commits into
igor-alexandrov wants to merge 2 commits into
Conversation
Version tags like @v5 are mutable: whoever controls the action repo can move the tag and run new code in our workflows. That matters most in release.yml, whose id-token permission mints the RubyGems trusted publishing credential — a moved tag there could publish a malicious gem. Pinning to full commit SHAs (with the version in a comment) freezes the code we run; Dependabot-style bumps update the SHA in review. Also drop contents: write from the release job. rubygems/release-gem runs `rake release`, which only pushes a git tag when the tag does not already exist — and on the `release: published` trigger it always does (the action even runs `git fetch --tags --force` first), so the job never needed write access. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The previous pin resolved the tag list lexically, which sorted three-digit minors like v1.321.0 before v1.99.0 and landed on a 2020 commit whose Ruby index predates 3.x — every job failed with "Unknown version 3.4". Resolve through releases/latest instead: v1.321.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Why
A security review flagged that all workflows pin actions by mutable version tag (
@v5,@v1). Whoever controls an action repo can move the tag and run new code in our workflows. The stakes are highest inrelease.yml: itsid-token: writepermission mints the RubyGems trusted-publishing credential, so a moved tag there could publish a malicious gem version.What
actions/checkout→fbc6f39(v5.1.0)ruby/setup-ruby→e551707(v1.99.0)rubygems/release-gem→7f96501(v1.4.1)contents: writefrom the release job.rubygems/release-gemrunsrake release, which skips the git tag + push entirely when the tag already exists (already_tagged?in bundler's gem helper) — and on therelease: publishedtrigger it always exists; the action even runsgit fetch --tags --forcebefore releasing. So the job only ever neededcontents: read(for checkout) andid-token: write(for trusted publishing).Notes
The remaining release-workflow posture was already good: RubyGems trusted publishing (no long-lived API key secret), an
environment: rubygemsgate, andpermissions: contents: readat the top level.🤖 Generated with Claude Code