Skip to content

test(ci): enforce the fork-execution invariant in claude-run.yml - #7026

Merged
kovtcharov-amd merged 2 commits into
mainfrom
fix/2948-fork-gate-guard
Nov 9, 2026
Merged

kovtcharov-amd merged 2 commits into
mainfrom
fix/2948-fork-gate-guard

Conversation

@kovtcharov-amd

@kovtcharov-amd kovtcharov-amd commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

The PR-review workflow checks out fork code while holding the Anthropic credential and a write-scoped token. It stays safe only because no step runs that code unless the PR comes from this repo, and until now a code comment was the only thing enforcing that. A unit test now fails CI if any step after a checkout installs, builds or runs the checked-out tree without requiring both pull_request_target and a same-repo head. It also fails on any action not on an explicit allowlist, on any other workflow that opts into unsafe PR checkout, and on any caller that asks for the evidence stage outside pull_request_target. The evidence stage is designed for pull_request_target only. Its gate now says so explicitly, and its only caller already runs on that event, so behaviour is unchanged.

Test plan

  • python -m pytest tests/unit/test_claude_run_fork_gate.py tests/unit/test_evidence_harness_failure_signal.py passes
  • The live workflow passes the guard; dropping the event check from Detect testable surface fails it
  • Each of these, injected into a copy of the live workflow, fails the guard: if npm test; then, while pytest; do, ! npm ci, { npm ci; }, cmd & npm ci, eval "$(cat x)", "$GITHUB_WORKSPACE/x.sh", ${{ github.workspace }}/x.sh, python3.12, pre-commit, docker build, an unlisted remote action, a local action
  • Parametrized cases cover the ||/negation bypasses, a fork-only or event-only gate, gh pr checkout as a checkout, and safe shapes that must not be flagged
  • actionlint clean in CI

Remaining on #2948

Refs #2948

The review workflow checks out fork code with secrets in scope, and the only
thing keeping that safe was a comment saying no step may run the checked-out
tree without the same-repo gate. A new test now fails if any step after the
checkout installs, builds or runs workspace code (or uses a local action)
without that gate, if any other workflow opts into unsafe PR checkout, or if
a caller requests the evidence stage outside pull_request_target.
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes labels Nov 9, 2026
@github-actions

This comment has been minimized.

… fork guard

The evidence stage is designed for pull_request_target only; its gate now
requires that event alongside a same-repo head, and the guard treats a step
as gated only when it requires both. The guard also catches more shell forms
and workspace paths, starts watching at a gh pr checkout, allows only listed
actions after a checkout, checks every workflow that calls claude-run.yml,
and ignores comments when looking for unsafe checkout.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 7b306eb Nov 9, 2026
33 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/2948-fork-gate-guard branch November 9, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant