ci: declare workflow-level contents: read on 8 build/test workflows#4527
ci: declare workflow-level contents: read on 8 build/test workflows#4527arpitjain099 wants to merge 2 commits into
contents: read on 8 build/test workflows#4527Conversation
Pins the default GITHUB_TOKEN to contents: read on the 8 workflows in .github/workflows/ that don't actually need any write scope: - benchmarks.yml: scheduled JMH benchmarks. - doctests.yml: jbang doctest runner. - format_check.yml: pmd / formatter checks. - integration.yml: redis integration test matrix. - snapshot.yml: snapshot deploy precheck (the actual deploy uses a separate Sonatype secret, not GITHUB_TOKEN). - spring-data-redis-integration.yml: spring-data-redis sanity check. - test-on-docker.yml: docker-based redis matrix. - unit-tests.yml: junit run. release-drafter.yml and version-and-release.yml are intentionally left implicit since they need write scopes. 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>
|
Thanks — makes sense. Before merging, we'll need to sanity-check that none of the flows rely on a write scope. One concrete flag: unit-tests.yml uses EnricoMi/publish-unit-test-result-action@v2. |
Per @ggivo's review: unit-tests.yml uses EnricoMi/publish-unit-test-result-action@v2, which writes test results back to the PR (needs pull-requests: write + checks: write). Plain contents: read would break it, so leaving that file out of this PR for a maintainer-driven follow-up that declares the right write scopes. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Thanks for the catch @ggivo, you're right. Dropped |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit b2c9f48. Configure here.
| default: '' | ||
|
|
||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
Restricted permissions break test result publishing in workflow
High Severity
test-on-docker.yml is restricted to permissions: contents: read, but it invokes the .github/actions/run-tests composite action, which uses EnricoMi/publish-unit-test-result-action@v2 at line 172. This action requires checks: write and pull-requests: write to post test results. This is the same action that caused unit-tests.yml to be dropped from this PR, but the dependency through the composite action was missed.
Reviewed by Cursor Bugbot for commit b2c9f48. Configure here.


Pins the default
GITHUB_TOKENtocontents: readon the 8 workflows in.github/workflows/that don't actually need any write scope:benchmarks.yml: scheduled JMH benchmarks.doctests.yml: jbang doctest runner.format_check.yml: pmd / formatter checks.integration.yml: redis integration test matrix.snapshot.yml: snapshot deploy precheck. The actual Sonatype deploy uses a separate secret, notGITHUB_TOKEN.spring-data-redis-integration.yml: spring-data-redis sanity check.test-on-docker.yml: docker-based redis matrix.unit-tests.yml: junit run.None call a GitHub API beyond the initial checkout.
release-drafter.ymlandversion-and-release.ymlare intentionally left implicit since they need write scopes; those are best declared by maintainers who own the release flow.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.YAML validated locally with
yaml.safe_loadon each touched file.Note
Low Risk
Low risk: only tightens GitHub Actions
GITHUB_TOKENpermissions to read-only for workflows that just check out and run builds/tests, reducing blast radius without changing build logic.Overview
Adds workflow-level
permissions: contents: readto multiple CI workflows (e.g.benchmarks.yml,doctests.yml,format_check.yml,integration.yml,snapshot.yml,spring-data-redis-integration.yml,test-on-docker.yml).This explicitly limits the default
GITHUB_TOKENto read-only for these jobs, reducing exposure from token leakage while leaving the workflows’ steps and triggers otherwise unchanged.Reviewed by Cursor Bugbot for commit b2c9f48. Bugbot is set up for automated code reviews on this repo. Configure here.