Skip to content

ci: declare workflow-level contents: read on 26 read-only workflows#8086

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

ci: declare workflow-level contents: read on 26 read-only workflows#8086
arpitjain099 wants to merge 1 commit into
pytorch:mainfrom
arpitjain099:chore/declare-workflow-perms-readonly

Conversation

@arpitjain099
Copy link
Copy Markdown

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

A mix of:

  • Composite-action tests: actions-test.yml, checkout-licensed.yml, checkout-test.yml, cross-repo-ci-relay-tests.yml, test_linux_job.yml, test_macos_job.yml, test_windows_job.yml, test-setup-miniconda.yml, test-setup-nvidia.yml, test-setup-python.yml, test-setup-uv.yml, test-export-matrix-variables.yml.
  • Linters and validators: bc-linter-tests.yml, lint.yml, scale_config_validation.yml, test-binary-size-validation.yml, test-validate-domain-library.yml, tests.yml, torchci.yml, validate-pypi-wheel-binary-size.yml, validate-repackaged-binary-sizes.yml.
  • Nightly triggers: trigger_nightly.yml, trigger_nightly_core.yml.
  • Lambda + webhook checks: lambda-runners.yml, lambda-runner-binaries-syncer.yml, lambda-webhook.yml.

None of those call a GitHub API beyond the initial checkout or use github.token / GITHUB_TOKEN.

Left implicit on purpose: workflows that pass github.token to a gh step or otherwise touch the API (actions-check-dist.yml, checkout-check-dist.yml, disable-flaky-tests.yml, pytorch-auto-revert-tests.yml, test-setup-ssh.yml, tflint.yml, update-inductor-expected-accuracy.yml, validate-nightly-binaries.yml, windows-ami-validation.yml) plus the explicit-write files (update-drci-comments.yml, validate-release-binaries.yml). Those scopes are best declared by maintainers who know the right shape.

Why

CVE-2025-30066 (March 2025 tj-actions/changed-files supply-chain compromise) exfiltrated GITHUB_TOKEN from workflow logs. 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 26 workflows
in .github/workflows/ that don't actually need any write scope. The
26 files are a mix of:

- composite-action tests (actions-test, checkout-licensed,
  checkout-test, cross-repo-ci-relay-tests, test_linux_job,
  test_macos_job, test_windows_job, test-setup-miniconda,
  test-setup-nvidia, test-setup-python, test-setup-uv,
  test-export-matrix-variables)
- linters and validators (bc-linter-tests, lint, scale_config_validation,
  test-binary-size-validation, test-validate-domain-library, tests,
  torchci, validate-pypi-wheel-binary-size,
  validate-repackaged-binary-sizes)
- nightly triggers (trigger_nightly, trigger_nightly_core)
- lambda + webhook checks (lambda-runners,
  lambda-runner-binaries-syncer, lambda-webhook)

None of those call a GitHub API beyond the initial checkout or use
github.token / GITHUB_TOKEN.

Left implicit on purpose (9 files): the workflows that pass
github.token to a gh-cli step or otherwise touch the API
(actions-check-dist, checkout-check-dist, disable-flaky-tests,
pytorch-auto-revert-tests, test-setup-ssh, tflint,
update-inductor-expected-accuracy, validate-nightly-binaries,
windows-ami-validation) plus the explicit-write files
(update-drci-comments, validate-release-binaries). Those scopes are
best declared by a maintainer.

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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@arpitjain099 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant