🏗️🔧:keep the branch under review off the runner - #1820
Merged
Conversation
A semgrep audit rule flagged this workflow for checking out code from the incoming pull request. It does not: the ref was `github.event.pull_request.base.ref`, the base branch. The rule matches any ref beginning `github.event.pull_request`, so it cannot tell the base from the head. The finding was still worth acting on. The branch under review was fetched so its commit messages could be read, which put a stranger's objects on a runner holding credentials that can write here, with nothing but a comment to stop a later step executing them. Those messages now come from the API, so nothing of the branch arrives at all, and the checkout takes the default rather than naming a ref that reads like the wrong one. The token is no longer left in .git/config either. Nothing here pushes. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5
✅ Deploy Preview for gh-pages-openinf ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
From the semgrep audit finding on
commit-queue.yml:40.The finding's literal claim is wrong
The rule says the workflow "checks out code from the incoming pull request". It does not — the ref was
github.event.pull_request.base.ref, the base branch. Reading the rule shows why it fired anyway:github.event.pull_request ...matches any continuation, so.base.refand.head.refare the same to it.It was still worth acting on
The workflow fetched the branch under review —
git fetch origin pull/N/head— so its commit messages could be read. That put a stranger's objects on a runner holding credentials that can write to this repository, with nothing preventing a later step from executing them except a comment saying not to. Comments do not enforce anything, and the next person to add a build step here would not necessarily read it.So the mechanism is gone rather than the warning silenced:
GET /pulls/{n}/commitsreturns them oldest first, merges filtered out — so nothing from the branch reaches the runner at all.ref:on the checkout. For this event the default is already the base branch, and naming it explicitly was indistinguishable, to a reader and to a scanner, from naming the wrong one.fetch-depth: 0, since no range is computed locally any more.persist-credentials: false, because nothing here pushes and a token in.git/configis one more thing to pick up.The rule's precondition no longer holds — there is no
actions/checkoutwith aref— so the finding clears legitimately rather than by suppression.Verification
nps test— 16/16 tasks, 63/63 testsref:in the workflow is in a comment explaining its absence