Skip to content

feat(agent): skill tool_whitelist may name a remote tool (#4291) - #4315

Merged
mstomar125 merged 2 commits into
mainfrom
issue-4291-whitelist
Nov 20, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-4291-whitelist

Conversation

@mstomar125

@mstomar125 mstomar125 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of #4291. User ruling on O3 (2026-11-20): a skill's tool_whitelist MAY name a remote tool by its node name, checked at turn time.

Agent lane. This touches packages/agent (Michael's lane). The user's sign-off for the #4291 remote-tool build stands in for Michael's.

What changed

The surface was already built so that a whitelist can only narrow what the gate offers: stage2_scoped_tools filters the executor's offered tools (all) by the matched skills' whitelist names, and the remote-tool host only puts a tool in all when it is enabled, its device approval verifies, a runner exists and (if its calls need confirmation) a confirmer is installed. So naming a remote tool needs no new path, and a whitelist can never make a tool available that the gate would not offer. What this PR adds is the visibility and the pinning tests.

  • Save time (core): no validation of whitelist names exists or is added. A skill save with a name that is not a built-in is accepted (test in typed_flat_updates_test.rs).
  • Turn time (agent): routing::unavailable_whitelist_warning finds names in the matched skills' whitelists that are neither on the offered surface nor built-in tools (a remote tool that is unknown, disabled, not approved here, changed since approval, a name twin, or has no runner/confirmer). The agent loop logs ONE warn! per turn with the names only (max 10 shown, each cut to 64 bytes, "and N more"); no description, schema or arguments. Those names simply match nothing, as before.
  • Unchanged: empty whitelist semantics; the existing fail-open when a whitelist resolves to nothing (the surface is then exactly what the gate offers); the existing treatment of unrecognised names as mutating for the score bar; the external-name twin rule (both dropped); built-in names win (a remote tool named like a built-in is never offered).

Tests (host + routing, over a real database)

built-in + approved remote offered and nothing else; unapproved remote not offered with the exact warning text; a peer-authored skill naming an unapproved tool: not offered, call refused as unknown, and offered once this device approves it; disabled tool not offered; binding changed after approval (hash mismatch) not offered; no confirmer: not offered; remote tool named like a built-in: the built-in is the one offered, no warning; two approved tools with one name: not offered; empty whitelist does not narrow; warning is names only and bounded.

Mutants: whitelist adds names the gate does not offer (bypass), whitelist offers the whole list, warning includes extra data, warning reports built-ins, warning bound removed, warning not logged. See the report for which tests killed which.

Requirements for the confirmation wiring (from review; for the later PR)

(a) DNS rebinding. The name resolved for the question must be PINNED and reused by the run (pass the resolved addresses into run), or the post-confirm check must compare the resolved IPs. Today the host rechecks only node_id and approval_tag after a yes.
(b) Args vs display. Runners cut the arguments in the 4096-byte text but run with the full arguments. The user must not confirm text they did not see: bind the answer to a DIGEST of the full arguments and show the real size with an expander, or refuse calls whose arguments exceed the display cap.
(c) Answer channel unreachable by the model and its tools. UI IPC only; no localhost HTTP route or token a spawned tool could reach; accept answers only from the session's own client. Never install the confirmer on a turn with no interactive UI (scheduled, headless): otherwise cli/mcp tools would be offered with an unauthenticated answer path.
(d) Replay. A random unguessable request id bound to session, turn, tool name and arguments digest; single use; cleared at turn end. Several calls in one tool-loop iteration are id-tagged so one yes cannot cover two.
(e) Display spoofing. Destination and arguments are attacker-influenced: show plain text, escape control and bidi characters, and carry the credential line as a separate structured field, never parsed from text.
(f) Credential references in the approval tag. Confirm the approval tag covers the credential references, so a secret edited between confirm and run is caught.
(g) Timeout ordering. A timeout drops the pending entry BEFORE a late yes can arrive. "Always allow" stays out.

Follow-up filed: #4316 (RemoteToolHost::execute checks the gate but not the turn's scoped surface, so a call to an approved remote tool that this turn's whitelist scoped out still runs after confirmation; proposal: refuse calls to tools not in the turn's offered list).

Review round 1 fixes

  • Warning names are cleaned of control and bidi characters (replaced by U+FFFD) BEFORE the cut, and de-duplicated AFTER the cut. Tests with \n, ESC, NUL and bidi overrides.
  • The warning is now emitted by log_unavailable_whitelist; a test captures the log: exactly one WARN line, names only, no control characters. Removing the warn! now fails that test.
  • Case-sensitivity test: R_GET / Get_Node against approved r_get are not offered and are warned about.

Remaining: confirmation wiring (plan, no code yet)

Today RemoteToolHost asks a CallConfirmer (confirm(&ConfirmationRequest) -> bool) inside execute, after the runner builds the text (confirmation_text, which may resolve the host first) and before the run; after a yes it re-checks the approval tag. The daemon installs no confirmer, so every cli/mcp tool and every non-GET (or credentialed GET) rest tool is not offered.

  1. Where it lives. A CallConfirmer implementation in the daemon (local_agent_service.rs, where the host is built per turn), holding a channel to the chat UI. The existing delete confirmation uses a different shape (the turn ends and the next user message answers, deletion_confirmation.rs). A remote call must be answered mid-turn, so it needs an in-turn question: emit a confirmation event to the session's stream and await the reply for that request id.
  2. What the request needs. ConfirmationRequest already has tool name, kind, the runner's destination text and the arguments. Add a request id (so a late or replayed answer cannot confirm another call), the session/turn id, and structured parts alongside the text (credential references, program/origin) so the UI can render credentials as their own always-visible line rather than parsing text.
  3. Bounded timeout. The await is bounded (e.g. 120 s, configurable); a timeout, a closed stream, a cancelled turn or an app shutdown all mean no. The pending map is cleared on turn end.
  4. Capped argument display. The runners already put credentials first and cut only the arguments (4096-byte text). The UI shows the credential line and the text uncut up to that bound, and shows full arguments behind an expander with a size cap; it never truncates the credential part.
  5. Default no. No answer, a malformed answer or an answer for another request id is a refusal. A yes is single-use for that call; nothing is remembered ("always allow" is a separate decision).
  6. Tests to land with it. Offered only with the confirmer installed (the existing host tests plus a daemon test); timeout is a refusal and runs nothing; late/duplicate/foreign-id answers are refused; the shown text keeps all credential references when arguments are huge.

Needs a decision before coding: whether the question appears as a chat message the user answers in place (consistent with deletes) or as a modal; the in-turn await works with either.

🤖 Generated with Claude Code

mstomar125 and others added 2 commits November 20, 2026 07:01
…turn time (#4291)

A whitelist only narrows what the gate offers; names that match nothing are
reported once per turn (names only). Save-time accepts any name.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…g and case sensitivity (#4291)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant