Skip to content

ci: declare workflow-level contents: read on 6 test/lint workflows#2955

Merged
soutaro merged 1 commit into
ruby:masterfrom
arpitjain099:chore/declare-workflow-perms-readonly
May 18, 2026
Merged

ci: declare workflow-level contents: read on 6 test/lint workflows#2955
soutaro merged 1 commit into
ruby:masterfrom
arpitjain099:chore/declare-workflow-perms-readonly

Conversation

@arpitjain099
Copy link
Copy Markdown
Contributor

Pins the default GITHUB_TOKEN to contents: read on the 6 workflows in .github/workflows/ that don't actually need any write scope:

  • c-check.yml: C-extension build check.
  • milestone.yml: PR milestone enforcer. The actions/github-script step only reads context.payload.pull_request and calls core.setFailed / core.info; no github.rest.* API call.
  • ruby.yml: Ruby test matrix.
  • rust.yml: Rust parser build.
  • typecheck.yml: steep typecheck.
  • windows.yml: Windows test job.

Left implicit on purpose:

  • bundle-update.yml does git push, gh pr create, and gh pr merge --auto.
  • comments.yml needs comment-write scope.

Both need write scopes that are best declared by a maintainer.

Why

CVE-2025-30066 (March 2025 tj-actions/changed-files supply-chain compromise) exfiltrated GITHUB_TOKEN from workflow logs and the leaked token retained whatever scope was issued at the workflow level. Pinning per workflow caps that runtime authority irrespective of the repo or org default, gives drift protection if the default ever widens, and is credited per-file by the OpenSSF Scorecard Token-Permissions check.

YAML validated locally with yaml.safe_load on each touched file.

Pins the default GITHUB_TOKEN to contents: read on the 6 workflows in
.github/workflows/ that don't actually need any write scope:

- c-check.yml: C-extension build check.
- milestone.yml: PR milestone enforcer. The github-script step only
  reads context.payload.pull_request and calls core.setFailed /
  core.info; no github.rest.* API call.
- ruby.yml: Ruby test matrix.
- rust.yml: Rust parser build.
- typecheck.yml: steep typecheck.
- windows.yml: Windows test job.

bundle-update.yml and comments.yml are intentionally left implicit:

- bundle-update.yml does git push, gh pr create, gh pr merge --auto.
- comments.yml needs comment-write scope.

Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files
compromise) exfiltrated GITHUB_TOKEN from workflow logs. Per-workflow
caps bound runtime authority irrespective of repo or org default,
give drift protection if the default ever widens, and are credited
per-file by the OpenSSF Scorecard Token-Permissions check.

YAML validated locally with yaml.safe_load.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Copy link
Copy Markdown
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@soutaro soutaro added the no-milestone This PR doesn't associate with a milestone. label May 18, 2026
@soutaro soutaro enabled auto-merge May 18, 2026 01:49
@soutaro soutaro merged commit 3810386 into ruby:master May 18, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-milestone This PR doesn't associate with a milestone.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants