#22578: CI: enforce explicit workflow token permissions
scripts
size: S
Cluster:
GitHub Actions CI Improvements
## Summary
- add explicit top-level `permissions` declarations to workflows that previously inherited repository defaults (`ci.yml`, `install-smoke.yml`, `workflow-sanity.yml`, `sandbox-common-smoke.yml`, `docker-release.yml`)
- keep release workflows least-privileged by default with `permissions: {}` and preserve existing job-scoped write grants
- add `scripts/check-workflow-permissions.py` and wire it into `workflow-sanity.yml` to enforce explicit top-level workflow permissions going forward
## Why
This addresses the least-privilege gap tracked in #11763 by removing implicit token scope inheritance in CI workflows.
## Validation
- `python3 scripts/check-workflow-permissions.py`
- `python3 scripts/check-composite-action-input-interpolation.py`
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR enforces explicit workflow token permissions as a security hardening measure. All workflows now declare top-level `permissions` blocks (either `contents: read` for read-only workflows or `permissions: {}` for release workflows with job-scoped grants). A new enforcement script prevents future workflows from inheriting implicit repository-default permissions.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are purely additive security hardening with no behavioral changes to existing workflows. The permission declarations match the actual requirements of each workflow, and the enforcement script correctly validates top-level permissions declarations without false positives.
- No files require special attention
<sub>Last reviewed commit: 73efd1d</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11765: fix(ci): restrict GITHUB_TOKEN permissions in workflows
by coygeek · 2026-02-08
87.0%
#17452: ci: Grant write perms for Issues for formal-conformance.yml
by thesomewhatyou · 2026-02-15
75.0%
#18924: fix(security): tighten permissions on cron/, browser/, settings/ dirs…
by rexlunae · 2026-02-17
71.1%
#22580: CI: pin workflow action refs to immutable SHAs
by Rohan5commit · 2026-02-21
70.0%
#17426: ci(formal): don't fail on fork PRs when PR comment is blocked
by mitre88 · 2026-02-15
70.0%
#11313: feat(ci): add staged release pipeline workflows (dormant)
by quotentiroler · 2026-02-07
69.6%
#19191: fix(security): harden cron file permissions to 0o600
by Kropiunig · 2026-02-17
68.2%
#16961: docs: warn against storing secrets in injected workspace files
by soumikbhatta · 2026-02-15
68.0%
#9474: fix: GitHub Actions not pinned to SHA digests in CI/CD workflows
by coygeek · 2026-02-05
67.7%
#3885: Upgrade GitHub Actions to latest versions
by salmanmkc · 2026-01-29
67.3%