Skip to content

fix(ci): hash-check the publish gate before the patch carry imports it - #16894

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/16813-patch-gate-hash-check
Nov 17, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/16813-patch-gate-hash-check

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #16813

Summary

The read runner's run job scans an oversize patch with the read-patch/publish-gate.mjs copy before refusing it. Code from the PR head can rewrite that copy in RUNNER_TEMP, and nothing checked it before the import, so a planted gate could make that first-pass scan answer clean. The scan job re-scans with the gate fetched from main, so this is hardening, not an open path.

Fix

  • The carry step reads GATE_SHA256 from steps.seal-copy.outputs.gate-sha256, the hash recorded from the base before the head checkout (added by feat(ci): carry the read runner's leg transcript to a clean upload job #16805).
  • patch_is_clean returns "hit" unless the copy is a regular file, not a link, whose SHA-256 matches. Inside the scan process the bytes are hashed again just before the import.
  • A planted, linked or missing gate therefore holds the oversize patch (patch-scan=hit), and nothing is carried.

Verification

  • node --test --test-concurrency=4 .github/actions/resolve-config/callers.test.mjs: 289/289 pass. That includes a new test which:
    • confirms the hash source is seal-copy, recorded before head code;
    • runs the step with a planted, a linked and a missing gate, and expects "hit" for each;
    • expects "clean" with the base gate.
  • Removing both hash checks makes the new test fail on the planted gate.
  • actionlint and zizmor --offline on pr-run-activity-read.yml report no findings.
  • Left out: the full .github suite, which CI runs.

Related

🤖 Generated with Claude Code

The run job's carry step scanned an oversize patch with the
read-patch/publish-gate.mjs copy, which head code can rewrite in
RUNNER_TEMP, and checked nothing before importing it. patch_is_clean now
imports the gate only when the copy is a regular file whose SHA-256
equals gate-sha256, recorded by seal-copy from the base before the head
checkout, and re-hashes the bytes inside the scan process just before the
import. A planted, linked or missing gate makes the scan answer hit, so
the oversize patch holds.

Closes #16813

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 17, 2026 17:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T17:45:03.228059Z 60a7247 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 60a7247be932fbf1709313e96b9c1bfbf24efbe6: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #16894

No security issues found. This pull request only tightens a check.

What changed. In .github/workflows/pr-run-activity-read.yml, the carry step's patch_is_clean now refuses to import read-patch/publish-gate.mjs unless three things hold:

  • GATE_SHA256 is set.
  • The copy is a regular file, not a symlink.
  • The copy's SHA-256 matches the hash recorded from the base.

The node process also hashes the bytes again just before the dynamic import(). Any failure returns non-zero, which takes the existing patch-scan=hit branch. The oversize patch is then removed and nothing is published, so the step fails closed.

What I checked.

  • Where the hash comes from. GATE_SHA256 is steps.seal-copy.outputs.gate-sha256. That step (L1498-L1514) copies the gate from .base/lib/publish-gate.mjs and hashes it. It runs before Check out the PR head at L1579, so code from the PR head cannot affect the recorded value. The output is a hex digest from sha256sum, which cannot carry an injection.
  • Unset or empty hash. The [ -n "$GATE_SHA256" ] guard returns 1, so the patch is held.
  • Hash-then-import race. A small window remains between the hash check and the import. The PR text notes that the scan job re-scans with the gate fetched from main, so a lost race does not open a path to publish a credential. The node-side re-hash also narrows the window. Not a finding.
  • Trust controls. No trust control is widened. The change touches no trusted-actor list, token scope, kill switch, merge hold or manifest.
  • Test file. .github/actions/resolve-config/callers.test.mjs is test-only. It adds a plant hook and GATE_SHA256 to the harness, plus a test that a planted, symlinked or missing gate yields hit. It has no runtime security surface.

Trusted-path scrutiny: .github/actions/resolve-config/** (test file only) and .github/workflows/pr-run-activity-read.yml. I read each file's whole change and the step it gates. The match alone is not a finding.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 60a7247be932fbf1709313e96b9c1bfbf24efbe6: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

What changed. In pr-run-activity-read.yml, the run job's carry step now takes GATE_SHA256 from steps.seal-copy.outputs.gate-sha256. That hash is recorded when the gate is copied from the base, before the PR head is checked out. patch_is_clean refuses the gate unless it is a regular file, not a link, whose SHA-256 matches, and the bytes are hashed again inside the node process just before import. This is the same check the transcript-carry step already uses (base_copy_matches plus the in-process re-hash at L2465-L2486).

Correctness checks (from reading the code; I ran nothing):

  • When the gate check fails, patch_is_clean returns non-zero. The caller then writes patch-scan=hit and deletes the oversize copy, so nothing is carried, which is what the issue asks for. The function runs inside an if, so the runner's bash -e does not stop the step on the return 1.
  • seal-copy (L1499) runs before Check out the PR head (L1579), and the new test checks that order.
  • The test's carry() helper now hashes the gate it writes and passes GATE_SHA256, so the existing cases keep their results:
    • "a gate that fails to load": the hash matches, the import fails, the result is hit.
    • "no gate": an empty hash gives hit.
    • "a gate never run as a script": the hash matches, the result is clean.
  • In the new test:
    • The linked-gate case keeps the real file's bytes, so only the bash [ ! -L ] check can turn it into hit. That pins the link check on its own.
    • The planted-gate case can only be held by the hash check.
  • createHash, symlinkSync and rmSync are already imported in the test file.

Closing issue #16813:

  • "patch_is_clean imports the gate only after checking its SHA-256 against the value recorded before the head checkout, and carries nothing on a mismatch, missing file or link, as the transcript step does": met.
  • "A test pins the check and runs the step with a planted, linked and missing gate": met by the new test in callers.test.mjs.

The PR body says 289/289 tests pass and that actionlint and zizmor are clean. That is the author's claim; I did not check it.

Neither the PR body nor the issue contains embedded instructions.

Loosened-check verdict: none. The wrapper supplied no verdict or patterns, so this review used fail with no consumer entries. The change tightens a check and loosens nothing.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 578733e Nov 17, 2026
83 of 84 checks passed
@kyle-sexton
kyle-sexton deleted the fix/16813-patch-gate-hash-check branch November 17, 2026 18:00
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement lane's patch carry imports an unchecked copy of the publish gate

1 participant