Skip to content

fix(ci): make security-fast hooks network-free - #136388

Merged
steipete merged 5 commits into
mainfrom
fix/ci-security-fast-local-hooks
Sep 2, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/ci-security-fast-local-hooks

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves an intermittent security-fast failure where pre-commit bootstraps remote hook repositories after checkout credentials have intentionally been removed. Fresh runners can then fail before detect-private-key runs, even when the pull request did not change scanner configuration.

Why This Change Was Made

security-fast now installs the exact scanner packages and generates one trusted repo: local, language: system configuration in RUNNER_TEMP. Pull requests load zizmor policy strictly from the exact base SHA; push and manual runs use the policy from github.workflow_sha.

This removes candidate-config and moving-branch fallbacks while preserving persist-credentials: false, the existing detect-private-key and zizmor filters, types, arguments, and serial execution.

User Impact

No runtime or product behavior changes. CI secret and workflow scanning no longer depends on anonymous GitHub hook-repository bootstrap, and pull requests cannot select their own scanner policy.

Root Cause And Owner

The security-fast job owned a remote-backed pre-commit configuration. Pre-commit initializes remote repositories before filtering to the requested hook, so an empty cache can execute an unauthenticated git fetch origin --tags before the scanner starts.

The canonical owner repair is in .github/workflows/ci.yml: install the pinned scanner executables once, invoke them through local system-language hooks, and select policy only from trusted immutable revisions. No token injection, URL rewrite, retry, timeout workaround, or helper script is added.

Evidence

Hosted Pre-Fix Reproductions

Local Pre-Fix Reproduction

With an empty PRE_COMMIT_HOME, the pre-fix workflow contract failed before scanner execution:

GIT_ALLOW_PROTOCOL=file GIT_CONFIG_COUNT=0 \
  pre-commit run --config .pre-commit-config.yaml --all-files detect-private-key

The locally available pre-commit 4.3.0 attempted to initialize https://github.com/pre-commit/pre-commit-hooks, reached git fetch origin --tags, and exited 3 because HTTPS was forbidden. The host package index does not expose 4.6.2, so this is contract reproduction, not exact-pin execution proof.

Regression Boundary

  • Before the repair, test/scripts/ci-security-fast-workflow.test.ts failed 3/3 because the local-only trusted scanner-config owner did not exist and the workflow retained remote/candidate fallbacks.
  • After the repair, the focused test passes 3/3. It executes trusted policy selection and verifies exact local-hook filters, types, arguments, require_serial, local-only repositories, missing-base fail-closed behavior, push/manual harness policy, poisoned-candidate rejection, and a Git deny wrapper that catches network verbs after global options such as git -c.
  • The static/executable workflow regression does not claim to execute the pinned scanners.
  • The changed-target routing regression now includes this workflow test for .github/workflows/ci.yml; its previously failing focused case passes.
  • P1 autoreview was scoped-clean with no actionable P0/P1 finding (0.93).

Remote Real-Tool Proof

The first ready-state exact-head attempt on 8484d958cfb2a9c60bca0175eaf6b761ffd9328a failed before execution because security-fast, preflight, and ARM each received zero-step runners. A single failed-job rerun then executed successfully:

The earlier standalone Testbox candidate proof remains unavailable:

The successful hosted security-fast rerun supplies the real pinned-tool execution proof; the executable regression supplies deterministic trusted-policy, poisoned-candidate, and network-Git contract coverage. Fresh exact-head CI is still required after the test-routing follow-up commit.

Validation

  • Focused post-rebase regression: 3 passed.
  • Focused changed-target routing case: 1 passed.
  • Changed-path dry-run selected testRoot and tooling for the workflow and both owning tests.
  • Workflow guard suite before rebase: 314 passed, 2 skipped.
  • actionlint: passed.
  • Changed-file formatting: passed.
  • Type-aware lint for the new test: passed.
  • Diff check: passed.
  • Local pnpm check:workflows is unavailable because the configured host package index stops at pre-commit 4.3.0.

Change Surface

  • Workflow/tooling: +30/-31, net -1.
  • Tests: +302/-0.
  • No runtime, configuration, token, timeout, retry, or release-note surface.

Landing Gate

Merge remains blocked until patched security-fast and all required exact-head CI checks pass on 979ed7d6108. The failed standalone Testbox infrastructure attempt is not candidate proof and must not be used as merge evidence.

Dependency And Codex Contract Checks

Upstream pre-commit source confirms Git environment cleanup preserves GIT_ALLOW_PROTOCOL and GIT_CONFIG_*, while remote repository initialization can fetch before hook filtering. The pinned pre-commit-hooks and zizmor metadata were checked for the effective entry points, filters, arguments, and serial semantics.

Sibling Codex source was inspected at 5f49aba876922d6f2f55caa153bbb0ed1b46feba, including codex-rs/git-utils/src/info.rs, codex-rs/core-plugins/src/startup_sync_tests.rs, and codex-rs/sandboxing/src/seatbelt_tests.rs. No Codex runtime or protocol change is involved.

Agent Transcript

Redacted implementation transcript
  • The user assigned the independently reviewed security-fast owner repair with an exact local-hook, trusted-policy, pinning, LOC, testing, and landing scope.
  • The executor reproduced the pre-fix remote-hook bootstrap failure with an empty pre-commit cache and local-only Git protocol policy before editing.
  • Dependency source inspection established that remote repositories can initialize before hook filtering and that the relevant Git environment controls survive into pre-commit Git subprocesses.
  • The first regression was rejected because it imitated pre-commit and private-key detection. It was replaced with an executable workflow-policy regression that does not claim scanner behavior.
  • The workflow was compressed to operational net -1 while preserving the reviewed hook filters, types, arguments, serial behavior, immutable policy selection, and credential boundary.
  • Test-audit found no low-value or implementation-only production seam. P1 autoreview reported no actionable P0/P1 finding.
  • The Ubuntu Testbox attempt ended in runner infrastructure failure before executing any candidate step, so exact-pin real-tool proof remains pending.
  • The amended commit was rebased once onto current origin/main; focused post-rebase tests, actionlint, formatting, type-aware lint, and diff checks passed.

@vincentkoc vincentkoc self-assigned this Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 2, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 2, 2026 15:30
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 3:47 PM ET / 19:47 UTC.

ClawSweeper review

What this changes

This PR replaces remote pre-commit hook bootstrapping in the security-fast CI job with explicitly installed local scanners and adds executable workflow-contract coverage.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The fix is not on current main, the PR is maintainer-authored/protected, and the reviewed patch contains no concrete correctness finding; its exact-head CI is still queued.

Priority: P2
Reviewed head: fdd4f3e0f9d8f54a93bedb448732edf69957806f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, net-negative workflow repair with executable contract coverage and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal CI repair is exempt from the external-contributor proof gate; the maintainer verification comment nevertheless records patch-identical real scanner executions, while queued exact-head CI remains the integration gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal CI repair is exempt from the external-contributor proof gate; the maintainer verification comment nevertheless records patch-identical real scanner executions, while queued exact-head CI remains the integration gate.
Evidence reviewed 5 items Introduced workflow owner repair: The PR creates a temporary local-only pre-commit configuration, reads zizmor policy from the exact PR base or trusted workflow harness, and runs both hooks with file-only Git protocol settings.
Current-main comparison: Current main still uses the remote-backed trusted pre-commit configuration and its origin-branch/candidate-config fallback, so the central repair remains unmerged.
Executable workflow coverage: The added test executes trusted-policy selection for pull-request, push, and dispatch cases, verifies missing-base failure, and checks that poisoned candidate configuration is excluded.
Findings None None.
Security None None.

How this fits together

The security-fast GitHub Actions job scans pull requests for secrets and unsafe workflow changes before the wider CI matrix proceeds. It selects trusted scanner policy, invokes the scanners, and reports the result to the pull-request gate.

flowchart LR
  A[Pull request or push] --> B[Security-fast workflow]
  B --> C[Trusted scanner policy]
  C --> D[Local scanner hooks]
  D --> E[Secret and workflow checks]
  E --> F[CI status]
Loading

Before merge

  • Resolve merge risk (P1) - This changes the CI security-scanning path; pending exact-head checks are still needed to confirm package installation and scanner execution on the current GitHub runner.
Agent review details

Security

None.

PR surface

Tests +280, Config -1. Total +279 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 280 0 +280
Docs 0 0 0 0
Config 1 30 31 -1
Generated 0 0 0 0
Other 0 0 0 0
Total 3 310 31 +279

Review metrics

Metric Value Why it matters
Production versus test delta workflow/tooling +30/-31; tests +280/-0 The operational change is net -1 line while the added test code exercises the trusted-policy contract and CI routing.

Merge-risk options

Maintainer options:

  1. Complete exact-head scanner validation (recommended)
    Allow the queued exact-head security-fast checks to confirm the new package installation and local-hook path before merge.
  2. Pause on scanner divergence
    If the exact-head job reports a scanner-entrypoint or policy mismatch, pause this PR for a focused dependency-contract review.

Technical review

Best possible solution:

Retain the local-hook and immutable-policy design, then land after the queued exact-head security-fast path confirms the same scanner coverage on GitHub Actions.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main's remote-backed pre-commit configuration and the PR-provided hosted failures establish a clear fresh-cache failure path, although this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes. The workflow owner replaces remote hook initialization with explicitly installed local executables while retaining the existing filters and trusted-policy boundary; current main confirms the problem is not already solved.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2c2e5014f71a.

Labels

Label justifications:

  • P2: This is a bounded internal CI reliability and security-scanning repair without direct runtime user impact.
  • merge-risk: 🚨 automation: Merging changes the workflow that installs and invokes repository security scanners, so a runner-specific mismatch could affect CI gating.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored internal CI repair is exempt from the external-contributor proof gate; the maintainer verification comment nevertheless records patch-identical real scanner executions, while queued exact-head CI remains the integration gate.

Evidence

What I checked:

  • Introduced workflow owner repair: The PR creates a temporary local-only pre-commit configuration, reads zizmor policy from the exact PR base or trusted workflow harness, and runs both hooks with file-only Git protocol settings. (.github/workflows/ci.yml:1782, fdd4f3e0f9d8)
  • Current-main comparison: Current main still uses the remote-backed trusted pre-commit configuration and its origin-branch/candidate-config fallback, so the central repair remains unmerged. (.github/workflows/ci.yml:1782, 2c2e5014f71a)
  • Executable workflow coverage: The added test executes trusted-policy selection for pull-request, push, and dispatch cases, verifies missing-base failure, and checks that poisoned candidate configuration is excluded. (test/scripts/ci-security-fast-workflow.test.ts:194, fdd4f3e0f9d8)
  • Review continuity: The current three changed files are byte-identical to the prior reviewed head, so the previous no-finding review remains applicable to the implementation bytes. (.github/workflows/ci.yml:1782, fdd4f3e0f9d8)
  • Related workflow-test routing: The changed-target routing expectation adds the new security-fast workflow test whenever ci.yml changes. (test/scripts/test-projects.test.ts:853, fdd4f3e0f9d8)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-02T15:40:31.936Z sha 8484d95 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T16:26:12.037Z sha 979ed7d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T18:16:54.908Z sha 4a35cef :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer verification — merged

Merged through the native prepare/merge workflow as 1b535dd2f4fb at 20:06:10 UTC on September 2. GitHub confirms Vincent Koc as the commit author. The verified pre-merge head was fdd4f3e, whose complete source tree is byte-identical to Vincent's reviewed 4a35cefa.

The repaired failure was pre-commit's remote-hook initialization, before private-key detection. Local/system hooks retain the pinned scanner versions, filters, immutable-base policy selection and fail-closed behavior. Actual scanner executions accepted clean input, rejected a temporary private key and an unsafe workflow, ignored candidate hook/policy poisoning, and rejected missing exact-base policy. Those invocations made zero network Git attempts and created no remote-hook repository cache entries. This removes remote Git hook downloads; it does not make package installation or every possible scanner HTTP request offline.

Verification includes 744 scanner/routing/workflow-guard tests with two existing skips, canonical workflow sanity, changed-file formatting/typechecking/guards/lint, and fresh full-branch Codex review through P2 with no actionable findings. The actual pinned-scanner proof covers the unchanged workflow bytes.

Exact-head CI run 33674687418 completed successfully at 20:00:58 UTC, including the actual security-fast scanner steps, all 14 UI end-to-end shards and both Windows jobs. The required openclaw/ci-gate passed. Native hosted-gate validation and final merge admission both passed. The latest ClawSweeper review had no source findings; its outstanding exact-head scanner-validation requirement is satisfied. No check was waived.

Earlier baseline failures were repaired separately on main: authenticated checkout, the CLI test split, and queue synchronization. The temporary baseline-repair candidate passed 45 real CLI process cases, six queue-ownership cases and the exact 16-file gateway subgroup (30 passed, one existing Mac-only skip); the original queue assertion was reproduced failing in that same shared-worker order. Those temporary copies were removed once main owned the canonical fixes. The final scheduled UI shard passed; this is not a claim that an intermittent UI root cause was repaired here.

The actual landed commit changes exactly three files: workflow +30/-31 (net -1), tests +280/-0. No runtime, runner-policy, UI or additional test changes are included. Post-merge inspection confirmed the active scanner path remains the reviewed local-hook implementation. The canonical checkout is clean on main and was fast-forwarded to the merge.

@vincentkoc

Copy link
Copy Markdown
Member Author

Landing evidence for exact head 979ed7d6108dea1b34a6f5dc281a8bef9fd02145:

  • ClawSweeper reported no findings. Its exact-head required-CI rank-up is explicitly skipped only for infrastructure verifier fallout: openclaw/ci-gate remains queued with no runner and no steps: https://github.com/openclaw/openclaw/actions/runs/33654076155/job/100346905341
  • Changed-surface proof passed: security-fast, preflight, checks-node-compact-small-53, Blacksmith Testbox check, and Blacksmith Build Artifacts Testbox.
  • The sole substantive red, hosted build-artifacts, is the identical known sqlite-session-lifecycle baseline (built CLI could not list bundled plugin artifacts at test/helpers/sqlite-sessions-transcripts-flip-proof-assertions.ts:7) reproduced on the prior exact head and independently on fix(update): keep first upgrade alive after package replacement #136395. The aggregate gate is downstream fallout, not a branch regression.
  • No rerun is justified: the repaired surfaces already passed, the baseline is unchanged, and rerunning the full graph would consume capacity without differential evidence.

Current main is 8c60cc9d2ca94f044e99394dc1bfc5828e2ed6cd; the full-clone merge-tree is clean (ab7ace2c1c344ccf77bd2a502a5c81ede3f2470d). No active release hold was found.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head 4a35cefa22e650f62ed9a08846b99b794e2aca23 applies the maintainer-requested test-audit cleanup only: it removes the fake Git-wrapper self-test and its now-dead call logging (-22 test LOC). The real trusted-policy, fail-closed workflow execution tests and changed-target routing assertion remain; workflow production behavior is unchanged.

Proof: focused security-fast + test-projects passed 433/433; pnpm check:workflows passed with pinned pre-commit 4.6.2 under Python 3.13; targeted format and Oxlint passed; the changed-plan dry run selected testRoot, tooling; git diff --check passed; fresh P1 autoreview found no findings. Current main 1212f991db46ad4ffe8c11198c175a5736392a15 merges cleanly (tree 8be453e783382cdb70a293018b9f79f8f1572e7c), with no active release hold. Fresh exact-head CI was allowed to start normally; no manual broad rerun was requested.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Reuse the gateway CLI fixture cleanup from #136469 (667ce2b) and
the landed startup-recovery queue assertions from #136473 (564e544).
These address independent lint and shared-worker test failures while
preserving all process, state, cancellation, and survivor assertions.

Keep Vincent Koc's scanner implementation and original PR ancestry unchanged.
The new commit also refreshes pull-request CI against main's authenticated
checkout repair from #136178.
Remove the temporary copies of the CLI fixture and startup queue test fixes.
Main now owns the CLI suite split in aef65cc and queue assertions in #136473.
Keeping the earlier fixture cleanup here conflicts with main's new shared
test support and health suite.

Restore the cumulative PR tree exactly to Vincent Koc's reviewed 4a35cef
without replacing his ancestry. The merge then retains main's canonical
test repairs and authenticated checkout fix from #136178.
@steipete
steipete merged commit 1b535dd into main Sep 2, 2026
206 checks passed
@steipete
steipete deleted the fix/ci-security-fast-local-hooks branch September 2, 2026 20:06
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
Use local/system pre-commit hooks for the exact pinned private-key and workflow scanners. This removes remote Git downloads from hook initialization, which previously failed on GitHub authentication before detection could run. Package installation remains a separate networked step.

Keep immutable trusted policy, existing scanner filters, and non-persisted checkout credentials. Add trusted-policy and fail-closed regression coverage and route it into the script-test inventory. Actual pinned scanner fixtures confirm clean inputs pass, private keys and unsafe workflows fail, candidate policy cannot override trusted policy, and missing immutable-base policy fails closed. Hook execution makes no network Git requests.

Verification: 744 focused tests passed with two existing skips; workflow sanity and changed-file formatting, typechecking, guards, and lint passed. Fresh independent Codex review found no actionable findings. Exact-head pull-request CI and the required openclaw/ci-gate passed: https://github.com/openclaw/openclaw/actions/runs/33674687418

Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants