ci: set explicit permissions on workflows missing them - #5627
Open
harshil-mistry wants to merge 1 commit into
Open
ci: set explicit permissions on workflows missing them#5627harshil-mistry wants to merge 1 commit into
harshil-mistry wants to merge 1 commit into
Conversation
harshil-mistry
force-pushed
the
ci-explicit-permissions
branch
from
August 25, 2026 07:33
9d18670 to
47361e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eight of the ten workflows here don't declare
permissions:, so theirGITHUB_TOKENfalls back to whatever the repository default is instead of being scoped to the job.pages.ymlandissues.ymlalready declare one, so this just brings the rest in line.All eight only read the repo, so
contents: readcovers them:ubuntu-tests.yml,windows-tests.ymlpre-commit.ymldocker-build-test.ymldocker-release.ymlrelease.ymlcheck_pypi_version.yml,windows_check_pypi_version.ymlI checked the two publishing workflows specifically, since those are the ones where a too-narrow scope would break a release:
docker-release.ymlauthenticates withsecrets.DOCKERHUB_USERNAME/DOCKERHUB_PASSWORDand pushes to Docker Hub, not GHCR — so it needs nopackages: write.release.ymluploads withTWINE_PASSWORD: secrets.PYPI_API_TOKEN, not OIDC trusted publishing — so it needs noid-token: write.Neither touches the GitHub API, so read is enough for both.
This is hardening rather than a bug fix — if the repo default is already read-only, nothing changes at runtime. It just stops these eight depending on that default.
Testing
I couldn't run these workflows from a fork, so I verified statically: each file was parsed with a YAML parser after editing to confirm it still loads and that
permissionsresolves to{'contents': 'read'}with the job list unchanged. The diff is additive only — three lines per file, no existing line touched. Every step in all eight was read to confirm none writes to the repo, creates releases, comments, or pushes to GHCR.