Skip to content

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

Open
arpitjain099 wants to merge 1 commit into
ruby:masterfrom
arpitjain099:chore/declare-workflow-perms-readonly
Open

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

Conversation

@arpitjain099
Copy link
Copy Markdown

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>
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