ci: declare workflow-level contents: read on 10 read-only workflows#6311
Open
arpitjain099 wants to merge 1 commit into
Open
ci: declare workflow-level contents: read on 10 read-only workflows#6311arpitjain099 wants to merge 1 commit into
contents: read on 10 read-only workflows#6311arpitjain099 wants to merge 1 commit into
Conversation
Pins the default GITHUB_TOKEN to contents: read on the 10 workflows in .github/workflows/ that don't actually use the default token for any write operation. Several of these are bump/sync workflows that look write-y from the filename, but the actual git push goes through a separate PAT (CLOUDSEC_MACHINE_TOKEN), not GITHUB_TOKEN: - arm-template-lint.yml: ARM template lint, no GitHub API. - bump-version.yml: workflow_dispatch; checkouts and pushes via CLOUDSEC_MACHINE_TOKEN. Default token unused. - ci-pull_request.yml: standard PR CI. The only secrets.GITHUB_TOKEN reference is COVERALLS_TOKEN passed to goveralls, which uses the token to authenticate with Coveralls (token read, not GitHub API write). - cloudformation-ci.yml: only the push trigger is active; the pull_request_target block is commented out. No GitHub API. - packaging.yml: build only. - sync-internal-cloudbeat-version.yml: workflow_dispatch; all git ops via CLOUDSEC_MACHINE_TOKEN. - sync-rule-templates.yml: same pattern; CLOUDSEC_MACHINE_TOKEN does the writes. - test-opa-coverage.yml, test-opa-policies.yml, unit-test.yml: standard test workflows, no GitHub API. eks-ci.yml is intentionally left out. It passes GITHUB_TOKEN to andrcuns/allure-publish-action which posts allure reports as PR comments, so it needs pull-requests: write. Better to let a maintainer declare that scope. Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files compromise) exfiltrated GITHUB_TOKEN from workflow logs. Pinning per workflow caps the runtime authority irrespective of 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. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Contributor
|
This pull request does not have a backport label. Could you fix it @arpitjain099? 🙏
|
Author
|
Hi maintainers, mergify is asking for a backport label and external contributors can't add labels themselves. Could you apply |
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.
Summary of your changes
Pins the default
GITHUB_TOKENtocontents: readon the 10 workflows in.github/workflows/that don't actually use the default token for any write operation. Several look write-y from the filename, but the actual git push goes through a separate PAT (CLOUDSEC_MACHINE_TOKEN) notGITHUB_TOKEN:arm-template-lint.yml: ARM template lint, no GitHub API.bump-version.yml: workflow_dispatch; checkouts and pushes viaCLOUDSEC_MACHINE_TOKEN. Default token unused.ci-pull_request.yml: standard PR CI. The onlysecrets.GITHUB_TOKENreference isCOVERALLS_TOKENpassed to goveralls, which uses the token to identify with Coveralls (token read for auth, not GitHub API write).cloudformation-ci.yml: only thepushtrigger is active; thepull_request_targetblock is commented out. No GitHub API.packaging.yml: build only.sync-internal-cloudbeat-version.yml: workflow_dispatch; all git ops useCLOUDSEC_MACHINE_TOKEN.sync-rule-templates.yml: same pattern;CLOUDSEC_MACHINE_TOKENdoes the writes.test-opa-coverage.yml,test-opa-policies.yml,unit-test.yml: standard test workflows, no GitHub API.eks-ci.ymlis intentionally left out. It passesGITHUB_TOKENtoandrcuns/allure-publish-actionwhich posts allure reports as PR comments, so it needspull-requests: write. Better to leave that scope decision to a maintainer.Related Issues
None. This is a standalone CI hygiene PR.
Why
CVE-2025-30066 (March 2025
tj-actions/changed-filessupply-chain compromise) exfiltratedGITHUB_TOKENfrom 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 ScorecardToken-Permissionscheck.Checklist
yaml.safe_loadon each touched file.GITHUB_TOKENis narrowed.CLOUDSEC_MACHINE_TOKENare unaffected by this scope change.