Skip to content

ci: Pin actions to commit SHAs and drop the release write permission - #102

Closed
igor-alexandrov wants to merge 2 commits into
masterfrom
claude/pin-workflow-actions
Closed

igor-alexandrov wants to merge 2 commits into
masterfrom
claude/pin-workflow-actions

Conversation

@igor-alexandrov

Copy link
Copy Markdown
Collaborator

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 in release.yml: its id-token: write permission mints the RubyGems trusted-publishing credential, so a moved tag there could publish a malicious gem version.

What

  • Pin every action in all four workflows to a full commit SHA, with the resolved version in a trailing comment:
    • actions/checkout → fbc6f39 (v5.1.0)
    • ruby/setup-ruby → e551707 (v1.99.0)
    • rubygems/release-gem → 7f96501 (v1.4.1)
  • Drop contents: write from the release job. rubygems/release-gem runs rake release, which skips the git tag + push entirely when the tag already exists (already_tagged? in bundler's gem helper) — and on the release: published trigger it always exists; the action even runs git fetch --tags --force before releasing. So the job only ever needed contents: read (for checkout) and id-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: rubygems gate, and permissions: contents: read at the top level.

🤖 Generated with Claude Code

igor-alexandrov and others added 2 commits August 19, 2026 09:27
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>
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.

1 participant