Skip to content

Enforce native CLI tool policies - #160700

Closed
eleqtrizit wants to merge 7 commits into
openclaw:mainfrom
eleqtrizit:1073
Closed

eleqtrizit wants to merge 7 commits into
openclaw:mainfrom
eleqtrizit:1073

Conversation

@eleqtrizit

@eleqtrizit eleqtrizit commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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 Grep to 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

  1. Native admission in src/agents/cli-runner/execute-plugin.ts did not evaluate configured profiles, layered allow/deny rules, or runtime agent/session restrictions.
  2. Policy resolution in src/agents/cli-runner/cli-native-tool-policy.ts used the CLI backend and execution identity instead of the selected model provider and runtime policy identity.
  3. Native Read, Write, and Edit operands were not contained by tools.fs.workspaceOnly, and a hook could rewrite an initially safe path outside the workspace without a second check.
  4. Relative native file operands could be checked against the prepared run cwd instead of the exact cwd reported by the native client.
  5. Native Bash standing grants and configured PATH were resolved from the execution agent instead of the runtime policy agent.
  6. When execution and policy session keys differed, src/agents/cli-runner/cli-native-tool-policy.ts discarded the admitted sessionEntry, allowing session permission modes such as read-only or guarded to be lost.
  7. Provider-native names were treated as policy names. Anthropic Grep therefore bypassed canonical read allow/deny matching and its native path operand 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

  • Reuse resolvePluginHarnessToolPolicies so native admission follows existing effective-policy composition.
  • Bind provider, runtime policy session/agent, execution defaults, filesystem policy, and native Bash grants to their established identities without erasing the admitted execution session restrictions.
  • Project provider-native tools through the backend-owned authority mapper before matching canonical OpenClaw policy names.
  • Adapt native filesystem schemas explicitly: Read/Write/Edit use file_path; Anthropic Grep uses optional path, defaulting to the reported native cwd.
  • Resolve relative operands against the exact absolute cwd bytes in the permission request and reject unbound relative operands.
  • Reuse the symlink-safe workspace containment validator before hooks and again after hook rewrites.
  • Preserve plugin/trusted hooks and execution approval as independent later gates, with no new configuration or default changes.

Why this does not conflict with related PRs

PR Governed layer Relation to this PR
#128805 Canonical projection of native tool calls into before_tool_call hooks Already in the base; this PR enforces effective policy and containment before and after that hook layer.

The 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

Scenario Final effect observed
Actual Claude Code 2.1.274 client, production Anthropic stdio adapter and permission handler, full profile, cwd inside workspace Client consumed the allow decision and wrote the expected bytes.
Same real client with cwd outside or in a whitespace-suffixed sibling Permission denied; no outside target was created.
Same real client with a main-agent Bash grant and then a worker policy agent without that grant Main-agent marker was produced; worker-policy marker was not created.
Same real client with selected-provider Write deny or minimal runtime policy session Permission denied; no target was created.
Process-backed hook rewrite from an inside path to an outside path Rejected after rewrite and before I/O; no outside target was created.
Differing execution/policy session keys with admitted read-only or guarded mode Native Bash remained denied or approval-gated; the policy-key split did not erase the session restriction.
Anthropic Grep projected to canonical read read allow admitted an in-workspace native path; read deny, an outside path, and a rewritten-outside path were rejected.
Actual Claude Code 2.1.289 through production stdio adapter and patched host permission handler; Write-allowed worker policy, distinct main/worker roots Execution-root Write creates the exact 14-byte marker; direct policy-root and sibling-root Writes are denied with absent targets; every tool result returns to the local model.
Same actual client, hook rewrites the execution-root Write to the distinct worker root Denied after rewrite; both original and rewritten targets remain absent (0 bytes).
Process-backed distinct-root fixture: main execution workspace, Write-allowed worker policy with its own different workspace and workspaceOnly Admitted execution-root Write creates exactly 14 bytes; distinct policy-root and sibling-root targets are denied with zero writer launches and absent files.
Same fixture, hook rewrites execution-root Write to the distinct policy root Revalidated after hook; denied with zero writer launches and both target files absent.
Earlier verified runtime tree: affected CLI-runner suites and Anthropic authority projection suite 83/83 and 5/5 tests passed respectively; production code is unchanged by this proof-only update.

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

  1. 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.

  2. 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.

  3. 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 workspaceOnly setting.

  4. 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 Grep to read.

  • 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.

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 3:25 PM ET / 19:25 UTC (Revision 9).

ClawSweeper review

What this changes

The 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
Reviewed head: 1c6eb579b84eecb751ea5569fc816b05ba9dd3e3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong real-client evidence and resolved earlier defects support the repair, while the cross-agent authority contract limits implementation confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Prior-head Claude Code 2.1.289 traces exercise the production host and Anthropic adapter, showing the allowed 14-byte execution-root Write and absent targets for direct and rewritten out-of-root denials. Source comparison preserves those policy/containment paths through integration; these remain prior-head observations, not fresh integrated-head execution or whole-Gateway admission proof. Owner acceptance is separate. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Prior-head Claude Code 2.1.289 traces exercise the production host and Anthropic adapter, showing the allowed 14-byte execution-root Write and absent targets for direct and rewritten out-of-root denials. Source comparison preserves those policy/containment paths through integration; these remain prior-head observations, not fresh integrated-head execution or whole-Gateway admission proof. Owner acceptance is separate. No stored-data contract changes.
Evidence reviewed 11 items Verified review identity and clean checkout: Origin identifies openclaw/openclaw. The checkout is the exact pinned original PR head; its raw parents are the previous reviewed head and pinned main integration parent. Initial and final status were clean. The supplied test merge is stale and was not used to infer merged behavior.
Introduced policy enforcement: The pinned introduced diff uses the existing harness policy resolver with the selected model provider and runtime policy identity, retains the admitted session entry, projects native capabilities, and checks native filesystem operands before and after hooks. Earlier findings about provider/session identity, request cwd bytes, post-hook validation, and Bash grant identity are addressed.
Current main still needs the repair: The fetched main implementation performs native availability, host-owned-tool rejection, canonical hook projection, and execution approval, but does not perform this PR's effective tool-policy matching or native workspace containment.
Findings None None.
Security Needs attention Settle cross-agent workspace authority: The policy agent supplies workspaceOnly while containment uses the execution workspace. Real-client proof confirms writes into that distinct root; the authorization meaning remains explicitly unaccepted.

How this fits together

The 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]
Loading

Decision needed

Question Recommendation
Should native tools governed by a different policy agent use the admitted execution workspace, and is the documented fail-closed upgrade acceptable? Approve the admitted execution-workspace contract: Agents and Security explicitly accept the demonstrated delegation and restrictive upgrade behavior, with operator-facing guidance for denied calls.

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

  • Resolve security concern: Settle cross-agent workspace authority - The policy agent supplies workspaceOnly while containment uses the execution workspace. Real-client proof confirms writes into that distinct root; the authorization meaning remains explicitly unaccepted.
  • Resolve merge risk (P1) - With distinct agent roots, a worker's workspaceOnly policy permits native writes in the admitted execution agent's workspace and rejects its own configured workspace; Agents/Security have not accepted that delegation contract.
  • Resolve merge risk (P1) - Existing native workflows that bypassed profiles, provider/session restrictions, workspace containment, or policy-agent Bash grants will stop working after upgrade; owner acceptance of this fail-closed change and operator-facing guidance remain outstanding.
  • Complete next step (P1) - Obtain Agents/Security acceptance of the mixed-agent execution-workspace contract and fail-closed upgrade behavior.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [medium] Settle cross-agent workspace authority — src/agents/cli-runner/execute-plugin.ts:82
Agent review details

Security

Needs attention: No supply-chain change or definite new bypass was found, but cross-agent workspace authorization still needs an owner decision.

PR surface

Source +107, Tests +756. Total +863 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 130 23 +107
Tests 5 756 0 +756
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 886 23 +863

Review metrics

Metric Value Why it matters
Security-boundary growth Production net +107 lines; tests and test support +756 lines The production growth has a stated policy-enforcement justification and reuses existing policy and containment owners.

Merge-risk options

Maintainer options:

  1. Record the workspace and upgrade decision (recommended)
    Obtain Agents/Security acceptance of the observed execution-root delegation and newly denied legacy calls before landing.
  2. Narrow mixed-agent admission
    If execution-root delegation is rejected, revise the authoritative admission contract and validate the resulting allowed and forbidden final effects.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The PR repairs a current native-tool policy and filesystem boundary bypass, a security-impacting defect independent of CI state.
  • merge-risk: 🚨 compatibility: Previously permitted native calls can become denied under existing restrictive settings, and that upgrade tradeoff remains unaccepted.
  • merge-risk: 🚨 security-boundary: Cross-agent workspace authority is concretely exercised but its intended delegation contract remains unsettled.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Prior-head Claude Code 2.1.289 traces exercise the production host and Anthropic adapter, showing the allowed 14-byte execution-root Write and absent targets for direct and rewritten out-of-root denials. Source comparison preserves those policy/containment paths through integration; these remain prior-head observations, not fresh integrated-head execution or whole-Gateway admission proof. Owner acceptance is separate. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Prior-head Claude Code 2.1.289 traces exercise the production host and Anthropic adapter, showing the allowed 14-byte execution-root Write and absent targets for direct and rewritten out-of-root denials. Source comparison preserves those policy/containment paths through integration; these remain prior-head observations, not fresh integrated-head execution or whole-Gateway admission proof. Owner acceptance is separate. No stored-data contract changes.

Evidence

Security concerns:

  • [medium] Settle cross-agent workspace authority — src/agents/cli-runner/execute-plugin.ts:82
    The policy agent supplies workspaceOnly while containment uses the execution workspace. Real-client proof confirms writes into that distinct root; the authorization meaning remains explicitly unaccepted.
    Confidence: 0.98

What I checked:

  • Verified review identity and clean checkout: Origin identifies openclaw/openclaw. The checkout is the exact pinned original PR head; its raw parents are the previous reviewed head and pinned main integration parent. Initial and final status were clean. The supplied test merge is stale and was not used to infer merged behavior. (1c6eb579b84e)
  • Introduced policy enforcement: The pinned introduced diff uses the existing harness policy resolver with the selected model provider and runtime policy identity, retains the admitted session entry, projects native capabilities, and checks native filesystem operands before and after hooks. Earlier findings about provider/session identity, request cwd bytes, post-hook validation, and Bash grant identity are addressed. (src/agents/cli-runner/cli-native-tool-policy.ts:23, 1c6eb579b84e)
  • Current main still needs the repair: The fetched main implementation performs native availability, host-owned-tool rejection, canonical hook projection, and execution approval, but does not perform this PR's effective tool-policy matching or native workspace containment. (src/agents/cli-runner/execute-plugin.ts:64, 62d0c5f3b66c)
  • Latest-release boundary: Inspection of v2026.9.8 also shows native hooks and execution approval without the introduced effective-policy and filesystem checks. No merged fixing PR or shipped implementation of this remaining repair was established. (src/agents/cli-runner/execute-plugin.ts:55, fc23bc864e45)
  • Integration preserves main's native ownership guard: Direct comparison with the previous reviewed source verifies that the integrated head adds host-owned-tool rejection before effective policy and preserves main's shared cancellation, iterator cleanup, and compaction handling. The policy helper is byte-identical to the previous reviewed head. These integrated main changes are not attributed to the PR's introduced delta. (src/agents/cli-runner/execute-plugin.ts:111, 1c6eb579b84e)
  • Mixed-agent workspace contract: The filesystem setting comes from the runtime policy agent, but containment uses the admitted execution workspace. Preparation independently resolves the execution workspace and requester policy identity. The added distinct-root cases intentionally characterize execution-root allowance and policy-root denial; they do not establish owner acceptance. (src/agents/cli-runner/execute-plugin.ts:82, 1c6eb579b84e)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record Agents/Security acceptance of the execution-workspace delegation and fail-closed upgrade.

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 (8 earlier review cycles)
  • reviewed 2026-09-28T20:44:54.804Z sha fe75cee :: needs real behavior proof before merge. :: [P1] Recheck the file path after hook rewrites | [P1] Resolve provider policy with the selected model provider | [P1] Use the runtime policy session for native admission
  • reviewed 2026-09-29T01:31:24.729Z sha 99e2a9f :: needs real behavior proof before merge. :: [P1] Validate native file paths using the request cwd
  • reviewed 2026-09-29T02:24:34.828Z sha a507948 :: needs real behavior proof before merge. :: [P1] Preserve the native cwd bytes when checking relative paths | [P1] Use the policy agent for native Bash allowlist approval
  • reviewed 2026-09-29T03:10:24.038Z sha a9e90b3 :: blocked before merge. :: none
  • reviewed 2026-09-29T19:41:03.783Z sha a9e90b3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T17:22:14.759Z sha d6bc0d0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T18:00:45.680Z sha 6f1c635 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T18:14:47.872Z sha 6f1c635 :: blocked before merge. :: none

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 29, 2026
@eleqtrizit
eleqtrizit requested review from a team and vincentkoc September 29, 2026 03:53
@eleqtrizit eleqtrizit self-assigned this Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 1c6eb579b84eecb751ea5569fc816b05ba9dd3e3
  • Maintainer: @eleqtrizit
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/cli-runner/cli-native-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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
@eleqtrizit

eleqtrizit commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Added process-backed, post-fix distinct-root coverage in src/agents/cli-runner/execute-plugin-native-effect.integration.test.ts. Production code is unchanged.

The execution agent is main; the runtime policy agent is worker, explicitly granted Write with workspaceOnly: true, and their configured workspace roots are different. Synthetic temporary directories only.

Observed/asserted sink milestones:

execution-root Write: allow; writer launches=1; file content matches; bytes=14
distinct-policy-root Write: deny; writer launches=0; file absent
outside-sibling-root Write: deny; writer launches=0; file absent
hook rewrite execution-root -> policy-root: deny; writer launches=0; original and rewritten targets absent
suite: 10/10 passed
Vitest: 5.75 s; wall: 10.64 s; maximum RSS: 1,516,120 KB
owning agents-other typecheck: exit 0
focused type-aware lint: 0 warnings, 0 errors
diff check: clean

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.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Actual Claude Code distinct-root final-effect evidence

Reviewed code head: 6f1c6354f2068729e959886ba0e1c955e6049af7. Client verified via claude --version: Claude Code 2.1.289. Production executePluginOwnedProcess → production Anthropic executeClaudeCli/stdio transport → installed client → host permission response → actual native Write → filesystem observation. A transparent callback wrapper recorded decisions without changing them.

An admitted test context supplies main execution identity and Write-allowed worker policy identity with separately configured roots and worker workspaceOnly: true. Four fresh isolated HOME/config/temp directories; loopback-only mock Messages API with synthetic authentication. No real provider account, paid inference, or real-user workspace was used. This proves the native permission/final-effect boundary, not whole-Gateway routing/admission preparation.

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 native effect\n (14 bytes); policy-root/sibling-root writes and the hook-rewritten policy-root write are denied with zero target bytes and absent files. The real client returned a tool result to the local model in every case. Measured: 5.14 s Vitest / 9.56 s wall, max RSS 1,437,468 KB. Each local server was closed and isolated state/markers were removed in finally. No production source changes or paid provider calls were made.

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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 5, 2026
@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Resolved the confirmed P1 merge conflict in integration commit 1c6eb579b84eecb751ea5569fc816b05ba9dd3e3, merging main 4d94a9fac61f2e83331a09df18ad35cdfb1faf5c without rewriting the prior reviewed history.

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:

  • Full non-live CLI runner directory: 740/740 tests, 56/56 files, five routed shards; 555.03 seconds wall, peak RSS 6,103,156 KiB.
  • Core production typecheck passed. Owning agent test-type graphs (agents-root, agents-other, agents-tools) passed; gateway-root, gateway-server, gateway-other, and infra graphs also passed.
  • Focused type-aware lint: zero warnings/errors across seven PR files, 9.6 seconds. Formatting, conflict-marker scan, ratchets, dependency pins, config baseline, plugin boundaries, patch guard, core graph boundary, and diff checks passed.
  • The initial typecheck failure was a checkout-install mismatch: old fs-safe 0.21.1 lacked current main’s required export. A frozen-lockfile install restored the existing 0.23.1 pin; no manifest/lock changes or source workaround were added.

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.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@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.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

@openclaw/openclaw-secops — please record an explicit authority decision for current head 1c6eb579b84eecb751ea5569fc816b05ba9dd3e3, together with an Agents maintainer response. You are already requested as reviewers; no submitted owner acceptance is currently recorded. This is the remaining decision in the durable review, not another proof request.

Proposed contract, matching the implementation: the admitted execution context owns the filesystem root. A distinct runtime policy agent contributes its tool restrictions and workspaceOnly setting, but does not substitute its configured workspace for the admitted execution workspace. Applying worker policy is therefore not, by itself, confinement to the worker’s configured directory. Cross-agent use is delegation into the execution workspace and must be accepted explicitly.

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.

@joshavant

joshavant commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixed by #174740 and #172026.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Closing as superseded. The enforcement gap this change targeted is resolved on main through the mediated tool surface instead of per-request policy checks in the permission callback:

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.

@eleqtrizit eleqtrizit closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: L 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