Skip to content

refactor(exec): deslop safe-bin argument validation - #161109

Merged
steipete merged 1 commit into
mainfrom
hostneutral/deslop-infra-safe-bin-0929
Sep 29, 2026
Merged

steipete merged 1 commit into
mainfrom
hostneutral/deslop-infra-safe-bin-0929

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Safe-bin argv validation split one scan across several private consumers, repeatedly carrying the same profile sets and index through parameter objects. The owner now scans arguments directly and shares one option-value consumer. Production: +70/-189/net -119. Tests: +0/-0/net 0. Docs: +0/-0/net 0.

User Impact

No intended behavior change. Denied flags, unknown or ambiguous long options, short clusters, literal-token safety, stdin markers, tokens after --, positional limits, and command-specific rejection remain unchanged. Public exports and SDK contracts are unchanged.

Evidence

Blacksmith Testbox tbx_01m3p5x5sd4nc634r78bz9n9zt (allocation run), frozen-lockfile install, pinned base 64ef24b267b18ab32dc4acbe967d8c50d138c175 and SHA-256 verification of the candidate file.

  • pnpm test src/infra/exec-safe-bin-policy.test.ts src/infra/exec-approvals-safe-bins.test.ts --maxWorkers=1: 152 passed, 28.773s wall.
  • A temporary differential harness compared the original and candidate validators over 383,859 argv/profile combinations, including cached and rebuilt option metadata, malformed flags, terminators, paths, globs, expansions, and positional bounds: all matched, 1.431s wall. The harness does not add recurring CI cost.
  • Independent Codex autoreview through P2: scoped-clean. Formatting and git diff --check passed.
  • node scripts/check-changed.mjs --base 64ef24b267b18ab32dc4acbe967d8c50d138c175 -- src/infra/exec-safe-bin-policy-validator.ts passed on the same lease in 29m3.059s, including production tsgo, all 27 selected test type graphs, lint, all dead-export scans and architecture guards.

This slice is published after focused proof and review under the maintainer's requested workflow. No hosted CI was dispatched or rerun for proof.

Hosted CI failures under investigation

CI run 36547570255 passed the 29-file exec-approval shard and all non-test gates, but three untouched Gateway/CLI fixtures failed on merge 042d258b into main 249d2270513b973f08cbe379aa355d2c5606c70c:

  • Job 109338135790: server.heartbeat-store-lifecycle.product-proof.test.ts, different-store case, followup agent.wait returned error at line 248 before the store change. The assertion does not retain the underlying error.
  • Job 109338135565: models-list.membership.integration.test.ts, retained discovery/aborted-case test, 60s timeout. This rewritten fixture entered through the merge ref after test(gateway): release catalog owners when a models-list membership case aborts #161095; the PR head contains the prior fixture. Cold startup is a lead, not an established cause.
  • Job 109338135759: doctor-config-preflight.process.test.ts, canonical state after Doctor repairs cron, 45s timeout.

A bounded search of main and unrelated PR runs found different failures, not these exact failures. The scripted Gateway fixtures do not invoke the safe-bin validator, but that source independence alone is not being presented as a reproduced inherited failure. No hosted jobs were rerun. Auto-merge remains armed while these failures are investigated; no fix or inherited-failure exception is claimed.

Coordinator attribution update

The heartbeat failure is independently confirmed on unrelated PR #160158, head b7fd7e3dacfa1573cce771728ffb2f18a2cd1838: run 36548505088, job 109341201797 fails the identical different-store case at line 248 with error instead of ok. That PR changes Doctor/daemon process census code and does not change the heartbeat fixture or safe-bin validator.

This PR changes only the safe-bin argument validator. None of the failing tests changes that owner or exercises its validator: the heartbeat synthetic provider emits sessions_spawn and text, the membership fixture exercises models.list/config.patch against a synthetic provider, and the Doctor process test exercises repair/readiness without executing safe-bin commands. The full Gateway can import exec infrastructure transitively; mere module reachability is not a claim that these flows evaluate safe-bin argv. Their failure owners are the follow-up run lifecycle, model-catalog startup/fixture lifecycle, and Doctor child startup respectively.

Only one additional comparison log was fetched for this attribution. No identical inherited failure has yet been established for the two timeout cases. A clean-main replay preserving their original shard membership and worker admission is being prepared; no CI rerun or passing replay is being treated as a fix.

The clean-main replay completed on 4e5b70b4c6284215e83f5aa799cafadb0b0f9a9e using Testbox tbx_01m3p9pk2d4r7jfn2t1yr9ywcx: the original membership shard passed 12 files / 130 tests in 72.297s wall (the formerly timed-out case: 29.583s); the original Doctor shard passed 2 files / 37 tests in 205.927s wall including its required runtime build (the formerly timed-out case: 12.166s). Both used the original selector order and native eight-worker admission. These passing replays do not establish a fix or an identical inherited failure. With only the heartbeat failure independently reproduced, this slice remains parked under the maintainer's stated inherited-failure criterion. Its reviewed head and auto-merge request are unchanged.

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 521d477e4403e8b3d4cb3429b5d31f80580c653f
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/infra/exec-safe-bin-policy-validator.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@steipete
steipete enabled auto-merge (squash) September 29, 2026 09:13
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 6:40 AM ET / 10:40 UTC (Revision 5).

ClawSweeper review

What this changes

The PR replaces several private safe-bin argument helpers with one scan and shared option-value handling while keeping the exported validation interface.

Merge readiness

✅ Ready for maintainer review

Current main and the latest release retain the earlier validator, so this cleanup remains distinct work. Source comparison found no changed allow or deny outcome, and no actionable patch defect emerged. The reported CI failures have no established link to the validator.

Priority: P3
Reviewed head: 521d477e4403e8b3d4cb3429b5d31f80580c653f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused parity evidence and compact patch support a sound refactor, with no concrete correctness or security finding.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The changed validator feeds safe-bin admission and then allowlist segment satisfaction. This maintainer-authored PR is exempt from external-contributor runtime proof; its reported Testbox tests and differential comparison support parity, while no production command-execution trace was supplied. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The changed validator feeds safe-bin admission and then allowlist segment satisfaction. This maintainer-authored PR is exempt from external-contributor runtime proof; its reported Testbox tests and differential comparison support parity, while no production command-execution trace was supplied. No stored-data contract changes.
Evidence reviewed 9 items Introduced change: The pinned merge-base-to-head patch changes only the validator; it consolidates option handling and positional scanning without changing the exported function signature.
Current-main necessity: Fetched current main still contains the earlier multi-helper implementation, so it has not absorbed this refactor.
Release check: The latest supplied release tag also has the earlier implementation; no tag contains the proposed head commit.
Findings None None.
Security None None.

How this fits together

Exec approvals checks agent commands before they run. For configured safe bins, the resolved executable and its arguments feed a profile validator whose result can satisfy an allowlist segment without an operator prompt.

flowchart LR
A[Agent command] --> B[Parsed arguments]
B --> C[Trusted safe bin check]
C --> D[Argument validator]
D --> E{Profile permits use}
E -->|Yes| F[Allowlist segment satisfied]
E -->|No| G[Other approval checks]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -119. Total -119 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 70 189 -119
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 70 189 -119

Review metrics

Metric Value Why it matters
Reported parity comparisons 383,859 argv/profile combinations; 0 mismatches reported The comparison targets the approval decisions most sensitive to this refactor.

Technical review

Best possible solution:

Keep a single validator owner with the documented safe-bin allow and deny behavior preserved at the exec approval boundary.

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

Not applicable: this PR reports a behavior-preserving refactor, not a defect. Its parity claim has a described differential comparison, which this read-only review did not execute.

Is this the best way to solve the issue?

Yes. The patch removes private helper indirection within the existing validator while retaining its facade, profiles, and observed decision branches.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3baf08ac9b1a.

Labels

Label changes:

  • add merge-risk: 🚨 security-boundary: The rewritten validator helps decide which commands may run without an operator approval prompt.

Label justifications:

  • P3: This is an internal cleanup with no intended user-visible behavior change or established regression.
  • merge-risk: 🚨 security-boundary: The rewritten validator helps decide which commands may run without an operator approval prompt.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The changed validator feeds safe-bin admission and then allowlist segment satisfaction. This maintainer-authored PR is exempt from external-contributor runtime proof; its reported Testbox tests and differential comparison support parity, while no production command-execution trace was supplied. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Pavan Kumar Gondhi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Yuval Dinodia: 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 (4 earlier review cycles)
  • reviewed 2026-09-29T09:17:01.256Z sha 521d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T09:43:06.982Z sha 521d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T09:57:24.360Z sha 521d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T10:24:51.936Z sha 521d477 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing decision: the remaining red is outside this PR's owner

This PR changes only exec-approval / safe-bin policy code in src/infra/exec-*. None of the remaining red cases reference exec approvals, safe bins, or allowlists:

  • extensions/codex/src/app-server/upstream-fork-import.test.ts: fails in fixture teardown with ENOTEMPTY: directory not empty, rmdir on its temp directory. This is a filesystem cleanup race. Three replays passed.
  • src/gateway/server.heartbeat-store-lifecycle.product-proof.test.ts: the identical failure was reproduced on an unrelated PR (evidence in the lane notes above).
  • src/gateway/server-methods/models-list.membership.integration.test.ts and src/commands/doctor-config-preflight.process.test.ts ("serves canonical state after Doctor repairs cron", a 45 s timeout):
    • neither failing case uses exec-approval or safe-bin code;
    • the Doctor file's exec-approval migration case is a separate test, and it passed;
    • clean-main replays of both passed.

Focused owner tests, scoped checks, type lanes and autoreview for this change are recorded above. Landing at the exact head under the maintainer's rule to land over failures outside the PR's owner. The Codex teardown race is tracked as a follow-up.

@steipete
steipete merged commit c8a83d0 into main Sep 29, 2026
264 of 270 checks passed
@steipete
steipete deleted the hostneutral/deslop-infra-safe-bin-0929 branch September 29, 2026 11:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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.

1 participant