Skip to content

fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] - #136546

Merged
mmaps merged 2 commits into
openclaw:mainfrom
mmaps:fix/fix-981-narrow
Sep 3, 2026
Merged

mmaps merged 2 commits into
openclaw:mainfrom
mmaps:fix/fix-981-narrow

Conversation

@mmaps

@mmaps mmaps commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Addresses an issue where a managed ACP session could list and call plugin tools excluded by its configured agent tool policy when the optional plugin-tools MCP bridge was enabled.

Why This Change Was Made

The bridge now resolves effective policy from the canonical managed-agent session context, reuses the standard profile/global/agent policy pipeline, bounds plugin discovery with the combined allow/deny rules, and applies the same ordered policy to the final MCP tool registry. The existing standalone agentless path is unchanged.

User Impact

Policy-denied plugin tools no longer appear in managed ACP tool discovery and direct calls to them are rejected, while permitted plugin tools remain available.

Evidence

  • The focused regression failed before the change and passes at 73aee804eb910a8fc2e2a3b5757539db8703ad5a.
  • node scripts/run-vitest.mjs src/mcp/plugin-tools-serve.test.ts passed 21 tests.
  • Targeted formatting and git diff --check passed.
  • The Codex MCP contract was checked directly at codex-rs/codex-mcp/src/rmcp_client.rs:610 and codex-rs/codex-mcp/src/connection_manager.rs:856: discovery uses tools/list, and dispatch uses tools/call.

AI-assisted implementation; source, dependency behavior, and tests were inspected directly.

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

@mmaps
mmaps marked this pull request as ready for review September 2, 2026 19:12
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 6:17 PM ET / 22:17 UTC.

ClawSweeper review

What this changes

The PR applies a managed ACP session’s effective tool policy when exposing plugin tools through the MCP bridge, hiding denied tools and rejecting their calls.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 5 items remain

The patch follows the canonical effective-policy pipeline and its focused test covers denied discovery and direct invocation. This maintainer-authored, protected PR should remain open for a maintainer to verify that the prior requested managed-ACPX process trace (or an explicit skip) is satisfied before merge.

Priority: P1
Reviewed head: 9c92d022c3f66b998b769d68b37295e0a14b01d6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, source-consistent repair with targeted regression coverage; process-boundary evidence remains the meaningful confidence upgrade.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; the available focused test is supplemental, while the prior process-trace rank-up remains a maintainer proof-sufficiency decision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; the available focused test is supplemental, while the prior process-trace rank-up remains a maintainer proof-sufficiency decision.
Evidence reviewed 6 items Managed bridge policy application: The changed bridge derives session context, resolves the effective agent policy, builds the repository-standard policy pipeline, and filters the resolved plugin tools before MCP handlers receive them.
ACPX caller boundary: The ACPX runtime creates a per-session delegate and injects the canonical session key into managed plugin-tool MCP child processes.
Focused regression coverage: The added test asserts that an agent-denied plugin tool is absent from discovery, returns an unknown-tool error on a direct call, and never executes while an allowed tool still runs.
Findings None None.
Security None None.

How this fits together

The plugin-tools MCP bridge starts a local MCP server for ACP sessions and supplies plugin tools to its discovery and call handlers. ACPX injects the managed session identity into that child process, which now resolves and filters tools using the agent’s policy.

flowchart LR
  A[Managed ACPX session] --> B[Session identity environment]
  B --> C[Plugin tools MCP bridge]
  C --> D[Effective agent policy]
  D --> E[Plugin tool discovery]
  E --> F[Policy-filtered tool registry]
  F --> G[MCP list and call requests]
Loading

Decision needed

Question Recommendation
Does the available post-review evidence satisfy the prior requirement for a managed ACPX child-process MCP trace, or is a documented skip acceptable for this security boundary? Verify the managed MCP trace: Confirm a redacted ACPX child-process trace demonstrates denied discovery and execution are blocked while an allowed tool succeeds.

Why: The provided PR body shows focused mocked handler coverage, while the prior completed review specifically required process-boundary evidence; later comment contents are not available in this review projection.

Before merge

  • Resolve merge risk (P1) - This changes an authorization boundary for plugin-tool execution; before merge, a maintainer should verify that the prior requested managed-ACPX child-process MCP trace is present or that its explicit skip is accepted.
  • Resolve merge risk (P1) - The patch adds net 44 production lines to a security-sensitive path; the use of the shared policy pipeline is justified, but process-level evidence remains the material risk reducer.
  • Complete next step (P2) - Maintainer: verify that the prior managed-ACPX MCP trace requirement is satisfied by later evidence, or explicitly accept its documented skip before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +44, Tests +70. Total +114 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 53 9 +44
Tests 1 71 1 +70
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 124 10 +114

Review metrics

Metric Value Why it matters
Production versus test delta production +44, tests +70 The production growth implements managed-policy resolution and canonical filtering; the added test covers permitted and denied plugin-tool behavior.

Merge-risk options

Maintainer options:

  1. Verify the process boundary before merge (recommended)
    Confirm the managed ACPX MCP trace or an accepted documented skip so policy denial is proven before plugin execution.
  2. Accept handler-level evidence
    A maintainer may accept the focused policy-pipeline test without child-process evidence, retaining the residual boundary-proof risk.

Technical review

Best possible solution:

Keep the shared policy resolver and pipeline, then land after a maintainer verifies a redacted managed-ACPX MCP trace showing denied tools are neither listed nor executed while an allowed tool works, or accepts a documented skip.

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

No high-confidence live reproduction is available in the supplied review material. Current source and the focused regression make the missing managed-agent policy filter reproducible at the owner boundary, but not through a real ACPX child process here.

Is this the best way to solve the issue?

Yes: reusing the canonical effective-policy resolver and ordered pipeline is the maintainable owner-boundary fix rather than adding a bridge-specific matcher. The remaining question is process-level proof, not the filtering design.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 55a60de5e7db.

Labels

Label justifications:

  • P1: A managed ACP session could otherwise expose and invoke plugin tools denied by its configured policy.
  • merge-risk: 🚨 security-boundary: The changed selection path determines which plugin capabilities an ACP session can discover and invoke.
  • 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 maintainer-authored PR is not subject to the external-contributor proof gate; the available focused test is supplemental, while the prior process-trace rank-up remains a maintainer proof-sufficiency decision.

Evidence

What I checked:

  • Managed bridge policy application: The changed bridge derives session context, resolves the effective agent policy, builds the repository-standard policy pipeline, and filters the resolved plugin tools before MCP handlers receive them. (src/mcp/plugin-tools-serve.ts:43, 9c92d022c3f6)
  • ACPX caller boundary: The ACPX runtime creates a per-session delegate and injects the canonical session key into managed plugin-tool MCP child processes. (extensions/acpx/src/runtime.ts:913, 9c92d022c3f6)
  • Focused regression coverage: The added test asserts that an agent-denied plugin tool is absent from discovery, returns an unknown-tool error on a direct call, and never executes while an allowed tool still runs. (src/mcp/plugin-tools-serve.test.ts:190, 9c92d022c3f6)
  • Codex MCP protocol check: Direct sibling Codex source inspection confirms MCP discovery uses tools/list and dispatch reaches client call_tool; local cache remoting does not independently establish repository ownership. (codex-rs/codex-mcp/src/rmcp_client.rs:633, 5adb68a49933ae446bf11935662c83dba55a0804)
  • Current-main topology: The fetched main head is later than this PR but does not contain its head commit, so the PR is not already merged through ancestry. (55a60de5e7db)
  • Feature-history routing: History identifies prior MCP policy work and a recent ACPX session-ownership fix as the closest established ownership trail; source-line introduction could not be verified because required historical blobs were unavailable offline. (src/mcp/plugin-tools-serve.ts:31, 471489159bf5)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

  • Verify or explicitly waive the prior redacted managed-ACPX MCP trace requirement before merge.

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-02T19:24:34.020Z sha 73aee804eb910a8fc2e2a3b5757539db8703ad5a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-02T21:18:22.560Z sha 88ba8f8f855ab484db4a18d06ada2344b942a873 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-02T21:53:24.837Z sha 9c92d02 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@mmaps
mmaps force-pushed the fix/fix-981-narrow branch from 88ba8f8 to 9c92d02 Compare September 2, 2026 21:23
@clawsweeper clawsweeper Bot added 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@mmaps

mmaps commented Sep 2, 2026

Copy link
Copy Markdown
Contributor 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:

@drobison00 drobison00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mira · claude-opus-5 · via @drobison00

APPROVE. The bug is real on current main, the fix sits at the correct owner boundary (it reuses the canonical policy pipeline rather than reimplementing filtering inside the bridge), and I could not construct a bypass. Verified at head 9c92d022 by reading the changed module plus its callers, callees, and the policy owner — not diff-only.

Independently reproduced, not taken on faith

I reverted only src/mcp/plugin-tools-serve.ts to its pre-PR state (6a802e9a378), kept the new test, and re-ran the suite:

× plugin tools MCP server > enforces global and managed-agent plugin tool policy
  → expected { tools: [ { …(3) }, { …(3) } ] } to match object { Object (tools) }
Test Files  1 failed (1)
     Tests  1 failed | 20 passed (21)

It fails for exactly the right reason — discovery lists both tools, i.e. the agent-denied plugin_denied is exposed — and the other 20 pass, so the regression is targeted rather than incidental. At head the full file passes 21/21.

Why this is the right fix, not merely a plausible one

  • Owner boundary. resolveEffectiveToolPolicy + buildDefaultToolPolicyPipelineSteps + applyToolPolicyPipeline are the canonical layered-policy owner; the bridge now consumes them instead of hand-rolling a second policy path. No duplicate policy is introduced.
  • Enforcement covers dispatch, not just listing. createPluginToolsMcpHandlers builds toolMap from the same filtered array it lists (plugin-tools-handlers.ts:77-80), so a denied tool yields Unknown tool and its executor is never invoked — the test asserts both. The automations alias fallback (:96-98) can only resolve to an entry already in that map, so it is not an escape hatch.
  • The pre-filter cannot silently over-restrict. collectExplicitAllowlist/collectExplicitDenylist are unions across layers, so threading the agent layer into discovery bounds only widens the allow set and narrows the deny set; the ordered pipeline does the real narrowing afterward.
  • stripPluginOnlyAllowlist does not de-fang the filter. I checked analyzeAllowlistByToolType specifically because every step sets that flag and this bridge serves only plugin tools: it returns policy unchanged and affects warning text alone, so the allow-filter survives intact.
  • The identity input fails closed. resolveToolsMcpSessionContext throws when a session key is present without a derivable owner, or when the encoded owner and explicit owner disagree — the server exits rather than serving unfiltered tools. extensions/acpx/src/runtime.ts:767-805 injects the session key and --openclaw-agent-id into the managed plugin-tools server, so the managed ACP path actually reaches the new code.
  • Exact-head CI: 113 check runs, 0 failures.

Non-blocking notes

  1. byProvider layers are resolved but never applied. resolveEffectiveToolPolicy returns globalProviderPolicy/agentProviderPolicy/providerProfile, and the bridge passes no modelProvider/modelId — correctly, since it cannot know the ACP backend's model — so those layers stay inert here. A deny expressed only under tools.byProvider still will not hide a plugin tool on this bridge. Worth one line in the PR body as a known limit so it is a decision rather than an oversight.
  2. User impact is slightly broader than "denied tools disappear." Because the agent layer is now applied, an operator whose agents.<id>.tools.allow names only core tools (no plugin entries, no group:plugins) will find plugin tools vanish from managed ACP sessions. That is the correct semantics and matches the agent path, but it is a visible behavior change worth a release-note sentence.
  3. Test fidelity nit. The mocked tools carry no plugin metadata, so getPluginToolMeta returns undefined and the pipeline classifies them as core tools — meaning the new test exercises name-based policy only, never plugin-group expansion (group:plugins, plugin-id entries), which is the allowlist shape most likely on a plugin-only bridge. Production is fine (real tools get meta from the WeakMap set in src/plugins/tools.ts), but a follow-up case with metadata attached would close the gap that matters most here.
  4. Sibling surfaces checked, no one-sided fix. openclaw-tools-serve.ts serves two host-selected ring-zero tools rather than the plugin registry (and hard-requires the session key), and node-claude-skill-runtime.ts serves only the workshop tool — neither exposes the plugin registry, so this invariant does not leave a matching hole behind. The remaining asymmetry is intentional: this bridge tolerates an absent session key to preserve the documented standalone/agentless use, which means a hand-wired plugin-tools server under a non-managed name still gets global policy only.

@mmaps
mmaps merged commit aa78c17 into openclaw:main Sep 3, 2026
114 checks passed
vincentkoc added a commit that referenced this pull request Sep 3, 2026
* refs/remotes/origin/main:
  fix(plugins): reject unverifiable pinned npm installs (#136725)
  improve(ui): lift sidebar section headers on hover and mark online owners (#136985)
  test(cron): reuse isolated run suite hooks (#137341)
  test(channels): reuse shared indexed call guards (#137350)
  fix(ui): sidebar header controls read misaligned after the + button lost its border (#137317)
  fix(qa-channel): preserve conversation kind for implicit actions (#137343)
  fix: target the source checkout in Control UI repair commands (#137354)
  chore: reduce CI job count and database test overhead (#137352)
  fix(ios): preserve chat live edge across keyboard transitions (#136660)
  refactor(control-ui): consolidate mention inbox requests (#137375)
  fix(openai): preserve ChatGPT HTTP status for retry pacing (#137146)
  fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] (#136546)
  test(queue): reuse shared deferred fixtures (#137338)
  fix(gateway): repair the Gateway E2E shard (browser suite project, skill resource argv, Codex diagnostic) (#137358)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…nclaw#136546)

* fix(mcp): enforce managed agent plugin tool policy

* fix(mcp): satisfy plugin policy lint

* Note: Managed ACP sessions now honor per-agent plugin-tool allowlists. Agents with restrictive core-only allowlists no longer expose plugin tools unless an applicable tool name, plugin ID, group:plugins, or * is explicitly allowed.
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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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