Repository navigation
[CI] Give the build-and-test workflow a read-only token - #10189
Merged
timosachsenberg merged 3 commits intoSep 18, 2026
Merged
Conversation
"Build and Test" runs on pull_request and builds and runs code from the branch under review, but declared no permissions and let actions/checkout persist its credentials in .git/config. For a pull request from a branch of this repository the default GITHUB_TOKEN is write-capable, so code under review could have read that credential back out and written to the repository. Nothing in this workflow needs it: no step and neither .github/actions/build nor .github/actions/dependencies references GITHUB_TOKEN or github.token. The rsync cache authenticates with its own SSH secrets, and the Actions cache uses the runtime token, which permissions: does not govern. The same action chain -- including the git submodule update --init calls for THIRDPARTY and vcpkg, all three submodules being public over HTTPS -- already runs with persist-credentials: false in release.yml, so anonymous submodule fetches are known to work here. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AEjmTqnBURLeb5Xb15fFdx
Contributor
|
Warning Review limit reachedNext included review available in 31 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
timosachsenberg
commented
Sep 18, 2026
timosachsenberg
commented
Sep 18, 2026
Second review suggestion from @timosachsenberg on #10189. The workflow now carries the two settings without commentary, matching release.yml; the reasoning stays in the commit message and the pull request. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AEjmTqnBURLeb5Xb15fFdx
timosachsenberg
deleted the
claude/harden-test-workflow-token-ce5w79
branch
September 18, 2026 11:17
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.
Description
.github/workflows/test.ymlruns onpull_requestand builds and runs code from the branch under review, but it declared nopermissions:block and letactions/checkoutpersist its credentials in.git/config. For a pull request from a branch of this repository the defaultGITHUB_TOKENis write-capable, so code under review could read that credential back out of the checkout and write to the repository.This adds the two lines that close that off:
permissions: contents: readat workflow level, so every job (including any added later) gets a read-only token;persist-credentials: falseon the checkout, so the token is not left behind for the built code to find.Why this is safe here
test.ymlreferencesGITHUB_TOKENorgithub.token, and neither does.github/actions/buildnor.github/actions/dependencies. The rsync build cache authenticates with its own SSH secrets, and the Actions cache uses the runtime token, whichpermissions:does not govern..github/actions/dependenciesrunsgit submodule update --initforTHIRDPARTYandvcpkg; all three submodules in.gitmodulesare public HTTPS URLs.release.ymlchecks out withpersist-credentials: falseand then calls the same./.github/actions/build, so these anonymous submodule fetches are what already happens on release builds. Eight of the other workflows also declarepermissions:;test.ymlwas one of the few without.Behaviour is otherwise unchanged — this touches only the token the job receives, not what it builds or tests.
Found while reviewing #10178, where a security linter flagged it against that PR's new job. It is not specific to that change — the exposure is pre-existing and workflow-wide (the existing
build-and-testjob already builds and runs the whole suite from the PR checkout), so it is split out here rather than carried along with the header file-set migration.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01AEjmTqnBURLeb5Xb15fFdx
Generated by Claude Code