Skip to content

ci: keep fork pull requests off privileged runners - #592

Open
walsykerem wants to merge 4 commits into
kernel:mainfrom
walsykerem:fork-pr-privileged-runner-problem
Open

walsykerem wants to merge 4 commits into
kernel:mainfrom
walsykerem:fork-pr-privileged-runner-problem

Conversation

@walsykerem

@walsykerem walsykerem commented Nov 21, 2026 •

Copy link
Copy Markdown

A maintainer can comment on a pull request to run the full test suite, including pull requests opened from a fork. That path checked out the fork's head commit on the project's own runners, machines that have passwordless sudo and a Docker Hub login. So anyone who can open a pull request could get code run as root on shared hardware, and the login step put a registry password on disk before the build started. Checkout also left the tree dirty, so a binary planted by one run could survive and run in the next.

The fix splits trust by runner. A new fork-checks job runs only when the dispatch names a repository other than this one, and only on a hosted runner with no secrets, no sudo and no registry login. It checks out the fork commit and runs make build, so contributors still get a compile signal.

The three self-hosted jobs now skip any dispatch that names a fork, and check out this repository at this workflow revision instead of a supplied repository and ref. That puts the Docker Hub login out of reach for fork code. Checkout cleans the tree by default, and the follow-up clean no longer spares bin/ or downloaded binaries, so no build output crosses between runs. The status comment reads whichever job ran.


Note

Medium Risk
CI trust-boundary and checkout behavior change: fork PRs lose full privileged test coverage, and status reporting logic must correctly map fork-only vs in-repo dispatches.

Overview
Fork PR test dispatches no longer execute untrusted code on self-hosted runners that have passwordless sudo, Docker Hub credentials, and shared disk state.

A new fork-checks job runs only for workflow dispatches naming an external repo: it checks out the fork commit on ubuntu-latest and runs make build with no secrets or registry login. Linux, macOS, and e2e jobs are skipped for those dispatches and otherwise check out this repository at the dispatched SHA (not the fork's tree).

Privileged jobs record tested_sha and report-pr-test validates it matches the PR head before posting a status; fork-only runs report fork-checks results. Workspace cleaning is stricter—git clean -ffdx no longer preserves bin/ or downloaded binaries across shared-runner runs.

Reviewed by Cursor Bugbot for commit 76f60e2. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread .github/workflows/test.yml Resolved
Self-hosted jobs gated on the dispatch not naming a fork still checked
out the default branch, so a same-repo /test run tested main and
report-pr-test posted that result onto the pull request commit.

The three privileged jobs now check out
ref: inputs.pr_head_sha || github.ref, so a same-repo dispatch tests the
PR commit while a push run has empty inputs and falls back to the pushed
ref. The test job exports the HEAD it checked out, and report-pr-test
skips status when that differs from the dispatched commit, so a run of
main can no longer be labelled as the PR result. Fork dispatches still
skip every privileged job, and fork-checks is still the only job that
checks out inputs.pr_head_repo, on a hosted runner.

proof/592-privileged-checkout.sh asserts these invariants. Old shape:
20/27, failing on the three missing checkout refs and on the missing
tested SHA. Fixed shape: 27/27.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9482d2b. Configure here.

Comment thread .github/workflows/test.yml Resolved

This branch has not been deployed

No deployments
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