From b65f86b53c6237dc1e96d3c975123f16c97a63c2 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sat, 21 Nov 2026 14:51:06 +1100 Subject: [PATCH] Refuse all fork pull requests on IUCLabs runners (#593) A pull_request job from a fork runs the fork's own workflow, Makefile and pre-commit config on the self-hosted runners before review. Fork PRs authored by members or collaborators were still allowed through. - job-started hook refuses every pull_request whose head repo differs from the base repo, regardless of author association - hook tests expect member fork PRs to be refused on default and infra runners Reviewed-on: https://git.unkin.net/unkin/argocd-apps/pulls/593 Co-authored-by: unkin-agent Co-committed-by: unkin-agent --- apps/base/iuclabs-runners/job-started.sh | 10 +++------- ci/test-runner-hooks.sh | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/base/iuclabs-runners/job-started.sh b/apps/base/iuclabs-runners/job-started.sh index aadc0cc..925b04d 100755 --- a/apps/base/iuclabs-runners/job-started.sh +++ b/apps/base/iuclabs-runners/job-started.sh @@ -33,13 +33,9 @@ esac case "${event}" in push | workflow_dispatch | schedule | merge_group | release) ;; pull_request) - trusted=$(jq -r ' - .pull_request.head.repo.full_name as $head - | if $head == null then false - elif $head == .repository.full_name then true - else (.pull_request.author_association | IN("OWNER", "MEMBER", "COLLABORATOR")) - end' "${GITHUB_EVENT_PATH}") || refuse "event payload unreadable" - [ "${trusted}" = true ] || refuse "pull request from untrusted fork" + same=$(jq -r '.pull_request.head.repo.full_name != null + and .pull_request.head.repo.full_name == .repository.full_name' "${GITHUB_EVENT_PATH}") || refuse "event payload unreadable" + [ "${same}" = true ] || refuse "pull request from a fork" ;; *) refuse "event not allowed on self-hosted runners" ;; esac diff --git a/ci/test-runner-hooks.sh b/ci/test-runner-hooks.sh index 69b3a8a..31d3b5d 100755 --- a/ci/test-runner-hooks.sh +++ b/ci/test-runner-hooks.sh @@ -29,7 +29,7 @@ done for e in push workflow_dispatch schedule merge_group release; do check 0 default "$e" push.json done -check 0 default pull_request pr-member.json +check 1 default pull_request pr-member.json check 0 default pull_request pr-same-repo.json check 1 default pull_request pr-fork-none.json check 1 default pull_request pr-fork-spoofed.json @@ -62,6 +62,7 @@ for r in terraform-git terraform-vault terraform-artifactapi terraform-authentik check 0 infra push push.json "IUCLabs/$r" check 0 infra pull_request pr-same-repo.json "IUCLabs/$r" check 1 infra pull_request pr-fork-none.json "IUCLabs/$r" + check 1 infra pull_request pr-member.json "IUCLabs/$r" check 1 infra issue_comment issue-comment.json "IUCLabs/$r" done for r in IUCLabs/app IUCLabs/terraform-netbox iuclabs/terraform-git evil/terraform-git IUCLabs/terraform-git-x "IUCLabs/terraform-git "; do