Repository navigation
Enforce native CLI tool policies - #160700
eleqtrizit wants to merge 7 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 5, 2026, 3:25 PM ET / 19:25 UTC (Revision 9). ClawSweeper reviewWhat this changesThe PR makes plugin-owned native CLI tools honor effective tool policies, admitted session restrictions, and workspace containment before and after argument-rewriting hooks. Merge readiness⛔ Blocked before merge - 5 items remain This PR remains necessary: current main lacks its effective-policy and filesystem checks. The integration addresses the prior conflict, and no new actionable code defect was found; the unresolved authority contract still warrants owner review. Likely related people: @vincentkoc and @steipete, medium-confidence routing candidates. Priority: P0 Review scores
Verification
How this fits togetherThe CLI runner connects OpenClaw agent sessions to plugin-owned coding clients. Native tool requests return to the host for policy, filesystem, hook, and approval decisions before the client performs the action. flowchart TD
A[Native client tool request] --> B[Effective agent and session policy]
B --> C[Workspace containment]
C --> D[Tool hooks and argument rewrites]
D --> E[Containment and current-run recheck]
E --> F[Execution approval]
F --> G[Allow or deny native action]
Decision needed
Why: The real-client evidence proves the implemented effects, but cannot establish whether access to the other agent's workspace is intended authority or whether the resulting caller breakage is accepted. Before merge
Findings
Agent review detailsSecurityNeeds attention: No supply-chain change or definite new bypass was found, but cross-agent workspace authorization still needs an owner decision. PR surfaceSource +107, Tests +756. Total +863 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one native admission owner, with an explicitly approved workspace-delegation contract and clear upgrade guidance for newly denied calls. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a focused path: current main admits native tools through hooks and exec approval without this effective-policy or workspace check. This review did not execute a failing current-main run. Is this the best way to solve the issue? Unclear overall: reusing the existing policy resolver and containment validator is appropriate, but the workspace authority contract requires owner intent before the implementation can be accepted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 62d0c5f3b66c. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
|
Superseded review request: the earlier review completed. A new exact-head review is being requested for the main-integration update; prior result remains in the durable review history. |
|
🦞👀 Re-review progress:
|
|
Added process-backed, post-fix distinct-root coverage in The execution agent is Observed/asserted sink milestones: These observations characterize the branch’s existing admitted-execution-root contract, not owner acceptance. The actual Claude Code executable is unavailable on this host, so this is not the requested production Anthropic-adapter/vendor-client recording. That artifact and Agents/SecOps acceptance of the mixed-agent root and fail-closed upgrade remain outstanding. |
Actual Claude Code distinct-root final-effect evidenceReviewed code head: An admitted test context supplies main execution identity and Write-allowed worker policy identity with separately configured roots and worker Sanitized observed terminal records: {"scenario":"execution-root","client":"Claude Code 2.1.289","executionAgent":"main","policyAgent":"worker","distinctRoots":true,"decisions":[{"tool":"Write","behavior":"allow"}],"modelMessages":2,"toolResultReturned":true,"fileExists":true,"bytes":14}
{"scenario":"policy-root","client":"Claude Code 2.1.289","executionAgent":"main","policyAgent":"worker","distinctRoots":true,"decisions":[{"tool":"Write","behavior":"deny","reason":"Path escapes sandbox root (<execution-root>): <policy-root>/marker.txt"}],"modelMessages":2,"toolResultReturned":true,"fileExists":false,"bytes":0}
{"scenario":"sibling-root","client":"Claude Code 2.1.289","executionAgent":"main","policyAgent":"worker","distinctRoots":true,"decisions":[{"tool":"Write","behavior":"deny","reason":"Path escapes sandbox root (<execution-root>): <sibling-root>/marker.txt"}],"modelMessages":2,"toolResultReturned":true,"fileExists":false,"bytes":0}
{"scenario":"rewritten-policy-root","rewrittenTargetExists":false,"client":"Claude Code 2.1.289","executionAgent":"main","policyAgent":"worker","distinctRoots":true,"decisions":[{"tool":"Write","behavior":"deny","reason":"Path escapes sandbox root (<execution-root>): <rewritten-policy-root>/marker.txt"}],"modelMessages":2,"toolResultReturned":true,"fileExists":false,"bytes":0}All four cases passed in one proof test. Allowed content exactly matches This closes the earlier missing-client evidence gap. Agents/SecOps approval of the admitted execution-root delegation and fail-closed upgrade remains a separate owner decision; the proof characterizes the current implementation and does not grant that approval. |
|
Resolved the confirmed P1 merge conflict in integration commit The single conflict was native-tool admission. The resolution retains main’s host-owned-tool rejection before effective policy, hooks, and approval, alongside backend canonical capability projection, admitted-session restrictions, and pre/post-hook filesystem checks. Main’s compaction lifecycle and iterator cleanup changes are preserved. Existing native Bash ownership coverage remains; an additional Grep-to-read regression verifies denial with no hook or approval call when the host owns read. Independent scoped source review found no actionable findings. Validation on the integrated tree with current-main pinned dependencies:
The generic changed-files runner expanded to 27 test graphs; it was deliberately stopped after seven passed, with cancellation exit 143. It is not reported as a completed/green full gate; remaining graphs and hosted CI are not covered by these results. Prior vendor-client recordings remain evidence for the prior head, not fresh integrated-head recordings. The mixed-agent execution-workspace authority/owner-acceptance concern is unchanged and remains separate. This update does not claim Agents/SecOps approval or merge readiness and does not request another ClawSweeper review. |
|
@clawsweeper re-review Please review current head 1c6eb57 after the main-integration conflict resolution. Preserved main native-tool guards; independent scoped review found no findings. Integrated-tree validation and its explicit limits: #160700 (comment). Mixed-agent authority and fail-closed owner acceptance remain unresolved; prior client evidence is identified by its original head. Fresh review only; no autofix or automerge requested. |
|
🦞👀 Re-review progress:
|
|
@openclaw/openclaw-secops — please record an explicit authority decision for current head Proposed contract, matching the implementation: the admitted execution context owns the filesystem root. A distinct runtime policy agent contributes its tool restrictions and Please reply accepting or rejecting this statement for the cited head: “We accept native execution-workspace delegation under the runtime policy agent’s restrictions, including when the configured agent workspace roots differ.” If worker-root confinement is the intended contract instead, please state that explicitly; we will need an intentional behavior change and updated allowed/forbidden evidence, not merely relabel the current trace. Operator guidance for the proposed contract: keep execution and policy workspaces aligned when worker-root confinement is required; do not treat switching policy identity as switching the native filesystem root. Native tool availability, effective profiles/provider/session restrictions, session permission modes, workspace containment before and after hooks, and policy-agent Bash grants are independent gates. Existing calls that depended on bypassing those gates now fail closed. On denial, check the selected policy/session, actual native cwd and admitted workspace, hook rewrites, and policy-agent grants; use an already-authorized tool/context rather than disabling containment or widening grants blindly. Please also explicitly accept this upgrade behavior and identify where this guidance should live in the operator documentation. Existing final-effect evidence establishes implemented behavior, not owner intent: #160700 (comment) (prior-head installed-client trace) and #160700 (comment) (integrated-head validation and limits). No cross-agent isolation guarantee, owner approval, or fresh integrated-head client trace is being inferred from those artifacts. This request does not resolve the blocker by itself: the authority decision remains pending until a submitted Agents/Security response records acceptance or selects the alternate contract. |
|
Closing as superseded. The enforcement gap this change targeted is resolved on
That design also settles the mixed-agent workspace questions raised in review by keeping a single owner for tool policy and filesystem checks. Thanks for all the review feedback. |
Summary
Plugin-owned CLI native tools could reach hooks and execution approval without enforcing the effective OpenClaw tool policy or filesystem workspace boundary. This change applies the shared policy resolver using the selected model provider and runtime policy session/agent identity, preserves admitted session permission modes even when execution and policy session keys differ, maps backend-native capabilities such as Anthropic
Grepto canonical OpenClaw policy names, validates native filesystem operands before and after hook rewrites, and keeps the existing execution-approval layer intact. It complements #128805: that PR governs hook projection, while this PR governs effective policy identity and filesystem containment around the hook flow.What was wrong
src/agents/cli-runner/execute-plugin.tsdid not evaluate configured profiles, layered allow/deny rules, or runtime agent/session restrictions.src/agents/cli-runner/cli-native-tool-policy.tsused the CLI backend and execution identity instead of the selected model provider and runtime policy identity.tools.fs.workspaceOnly, and a hook could rewrite an initially safe path outside the workspace without a second check.src/agents/cli-runner/cli-native-tool-policy.tsdiscarded the admittedsessionEntry, allowing session permission modes such asread-onlyorguardedto be lost.Greptherefore bypassed canonicalreadallow/deny matching and its nativepathoperand was not checked as a filesystem path.The net effect was that a restricted CLI-backed agent could invoke capabilities or filesystem effects that its effective OpenClaw policy or admitted session mode did not grant.
Why this design
resolvePluginHarnessToolPoliciesso native admission follows existing effective-policy composition.file_path; AnthropicGrepuses optionalpath, defaulting to the reported native cwd.Why this does not conflict with related PRs
before_tool_callhooksThe branches share the native permission path, but the responsibilities compose: hook projection does not replace admission policy, and admission policy preserves the hook contract.
Evidence
read-onlyorguardedmodeGrepprojected to canonicalreadreadallow admitted an in-workspace nativepath;readdeny, an outsidepath, and a rewritten-outsidepathwere rejected.The current-head real-client diagnostic recording is published at #160700 (comment). The sink-level observations are the created/absent files and Bash markers from the real-client/process-backed paths plus the exact native permission responses asserted by the focused suites.
SDK / caller upgrade contract
Callers whose native tools are granted by the effective runtime policy retain access and continue through hooks and execution approval. Calls that relied on bypassing a restrictive profile, canonical capability mapping, admitted session permission mode, provider rule, runtime session/agent restriction, workspace boundary, exact request-cwd binding, policy-agent Bash grant, or post-hook rewrite validation now fail closed. This restores the documented policy boundary without changing public schemas or caller APIs.
Boundary decisions requested from owners
Agents owners: confirm that plugin-owned native tools honor effective policy using the selected model provider and runtime policy session/agent identity, while admitted execution-session permission modes remain independently effective.
Security owners: confirm that native Read/Write/Edit and canonical-read provider tools remain inside the authorized workspace when resolved from the exact native request cwd before and after hook rewrites, and that native Bash standing grants resolve from the runtime policy agent.
Agents and Security owners: settle the existing mixed-agent workspace contract when execution and runtime policy agents have distinct workspace roots; this PR currently checks the admitted execution workspace under the policy agent's
workspaceOnlysetting.Agents and Security owners: evaluate the attached real-client distinct-root diagnostics against your workspace decision. The installed Claude client now verifies the implemented execution-root allow and nearest out-of-root denials; evidence characterizes the implementation rather than granting owner acceptance.
Testing
Current-head actual Claude Code 2.1.289 diagnostic matrix: four distinct-root final effects passed through the production host/Anthropic adapter; 5.14 s Vitest / 9.56 s wall, maximum RSS 1,437,468 KB. Isolated HOME/config/state and synthetic local model; no paid inference.
Added four distinct-root final-effect cases in
src/agents/cli-runner/execute-plugin-native-effect.integration.test.ts. Focused suite: 10/10 passed, 5.75 s Vitest / 10.64 s wall; maximum RSS 1,516,120 KB. Focused type-aware lint and diff checks passed. These are isolated post-fix process-backed characterization tests.Prior runtime-tree verification: four affected CLI-runner suites — 83/83 passed; production code unchanged.
Anthropic native authority projection suite — 5/5 passed, including
Greptoread.Production core typecheck — passed.
Prior runtime-tree verification: routed core-test type graphs — 26/26 passed.
Focused type-aware lint and
git diff --check— passed.Earlier real Claude Code 2.1.274 matrix through the production stdio adapter and permission handler — allowed and forbidden final effects passed.