Skip to content

[CI] Give the build-and-test workflow a read-only token - #10189

Merged
timosachsenberg merged 3 commits into
developfrom
claude/harden-test-workflow-token-ce5w79
Sep 18, 2026
Merged

timosachsenberg merged 3 commits into
developfrom
claude/harden-test-workflow-token-ce5w79

Conversation

@timosachsenberg

Copy link
Copy Markdown
Contributor

Description

.github/workflows/test.yml runs on pull_request and builds and runs code from the branch under review, but it declared no permissions: block 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 read that credential back out of the checkout and write to the repository.

This adds the two lines that close that off:

  • permissions: contents: read at workflow level, so every job (including any added later) gets a read-only token;
  • persist-credentials: false on the checkout, so the token is not left behind for the built code to find.

Why this is safe here

  • Nothing in the workflow needs the token. No step in test.yml references GITHUB_TOKEN or github.token, and neither does .github/actions/build nor .github/actions/dependencies. The rsync build cache authenticates with its own SSH secrets, and the Actions cache uses the runtime token, which permissions: does not govern.
  • The submodule fetches still work anonymously. .github/actions/dependencies runs git submodule update --init for THIRDPARTY and vcpkg; all three submodules in .gitmodules are public HTTPS URLs.
  • The pattern is already proven in this repository for this exact action chain. release.yml checks out with persist-credentials: false and 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 declare permissions:; test.yml was 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-test job 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

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01AEjmTqnBURLeb5Xb15fFdx


Generated by Claude Code

"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
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ce86ee68-572c-43db-a1d9-c3ac62bb4469

📥 Commits

Reviewing files that changed from the base of the PR and between c2da68a and 069f409.

📒 Files selected for processing (1)
  • .github/workflows/test.yml

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread .github/workflows/test.yml Resolved
Comment thread .github/workflows/test.yml Resolved
timosachsenberg and others added 2 commits September 18, 2026 12:27
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
timosachsenberg merged commit 40b59ac into develop Sep 18, 2026
11 of 12 checks passed
@timosachsenberg
timosachsenberg deleted the claude/harden-test-workflow-token-ce5w79 branch September 18, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant