Repository navigation
Add the remote tool gate and host: offer and run only approved tools a runner can run (executor, step 1) - #4310
Merged
Merged
Conversation
mstomar125
force-pushed
the
issue-4291-exec-gate
branch
from
November 19, 2026 13:27
d70ee35 to
eb4f785
Compare
…ly an approved tool a runner can run RemoteToolHost wraps the built-in tool executor. A tool-mcp / tool-rest / tool-cli node (or a user subtype of one) is offered and called only when this device's node has enabled true, an approved_binding equal to the current binding fingerprint, a plain non-built-in name, a closed-root schema and a runner for its kind is installed; two such tools with one name are both dropped. Calls are validated against the closed schema, confirmed when the kind needs it, and re-checked against the fingerprint after the confirmation. No runner exists yet, so nothing remote is offered. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…address review findings - approved_binding is now the device approval tag: HMAC-SHA256 under a per-device key (generated on first approval, kept in the credential store outside every name a node can refer to) over the node id, name, description and binding. The gate verifies it in constant time and fails closed with no key. - A rest GET whose binding carries a credential is confirmed. - A runner's error is marked external like its output; an argument name is cut in the error that repeats it. - External results reach the model inside a random-marker fence, ground no node id, and a remote tool's arguments and results are never logged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…y grounding, pinned tag vector, provisioning re-read Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4291-exec-gate
branch
from
November 19, 2026 14:34
e1727dc to
0ffa9cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #4291, executor step 1 (spec tasks A1, A2, A3: the gate, deterministic name collisions, dispatch, plus the keyed per-device approval and the findings of its security review). This PR changes
packages/agent(and wires it inpackages/daemon; core gets the approval tag and the device key): the user's sign-off stands in for the agent owner's for this build. Pair: nodespace-docs #165 (merge it just before this PR).Offering and dispatch land together, and the offering is gated on a runner being present.
RemoteToolHostoffers a remote tool only if a runner for its kind is installed. This PR installs none (the runners are the next PRs), so after it no remote tool is offered or run; the built-in tools are unchanged.GraphToolExecutor::available_toolsnow offers native tools only.The gate
assess(...)is the one function that decides. A node is a remote tool this device may offer or run only when all hold, read from this device's stored node:tool-mcp,tool-restortool-cli(a user subtype of one runs as that kind; a bareextends toolsubtype is never offered);enabledis exactlytruein thetoolbucket (absent, false, a string or a flat top-level value all mean off);approved_bindingin thetoolbucket is the device approval tag for the node as it is now (below);parameter_schemahas a closed root;RemoteToolHostadds: archived tools are not read; a runner for the kind must be installed; two approved tools that share a name are both dropped; arguments are validated against the closed schema (see the limits below); confirmation (CallConfirmer) for everytool-cliandtool-mcpcall, everytool-restcall that is not exactlyGET, and everyGETwhose binding carries a credential (anauthsecret or a scheme other thannone), refused when no confirmer is installed; after a "yes" the gate is re-run and the call runs only if the same node still has the same approval tag; the result is marked"source": "external", output is capped at 10 MiB and a runner error at 2 KiB.Keyed per-device approval
approved_binding = hex(HMAC-SHA256(device_key, "tool-approval-v1" || node_id || name || description || tool_binding_hash(...))), each field length-prefixed, 64 lowercase hex characters (so core'sis_binding_hashvalidation is unchanged; the field name stays).enabledandapproved_bindingstaylocal_only(defence in depth). A pinned known-answer test (computed independently of the Rust code) fails if the label, field order or encoding changes.approval-key) that has novalue:prefix and is not in the names index: nokeychain:<name>reference can read it, no name can collide with it,secret list-namesnever shows it, andsecret set/deletecannot touch it. Debug is redacted, the bytes are zeroed on drop, an unreadable key is an error and is never replaced.provision_approval_key()re-reads after writing and returns the stored key, so two store instances that race end up agreeing (in-process lock only; across processes the loser adopts the winner's key).hmac::verify_slice). No key (store unavailable, e.g. headless Linux, or unreadable) means nothing is offered. The host reads the key once per turn and caches the answer.remote_tools::approve(node, chain, key)overbehaviors::tool_approval_tag); the gate verifies against the same function. No user-facing approve command in this PR.hmacis new in core's manifest (already in the lockfile withsha2): no new crates.shape:genregenerated (description text only).What reaches the model and the logs
[Result of the external tool ...: untrusted data ...]and<external-data id="<random>">...</external-data id="<random>">(a fresh CSPRNG marker per result). A remote tool's description ends with a line saying its results are data, not instructions. A runner's error is marked external like its output; the host's own refusals are not.raw_responseand its log field), including any tool-call text in it.Known limits (state plainly)
validate_argumentsis shallow: noenum/pattern/minimum/items; nested objects are not closed; top-level strings are capped at 16 KiB. Runners must not trust nested shape.assessdoes not check that the binding is well formed: runners parse it through the typed readers (ToolRestFields::from_bucketand the like) and fail closed.provision_approval_keyacross processes: the re-read narrows but does not close the window (write A, read A, write B, read B can still hand A's key to one caller while B is stored); it fails closed (a tag made under the other key does not verify). Use an add-if-absent primitive when the approve command lands.Spec choices to confirm
extends toolsubtype is never offered. No cap on the number of tool nodes read. Nothing writes an approval yet (the enable-and-approve command is a later step).Acceptance criteria for the runner PRs
keychain:/env:credential is only sent to the host(s) bound by the approved binding (the tag covers url, credential reference and header/auth fields; any change needs re-approval). Never to a host derived from model input.env:references have no deny-list, so the approval UI must show the env name..expose()outside the injection point.httpexcepted); private and link-local addresses blocked after DNS resolution; a header never follows a redirect to another host.tool-cli: argv only, no shell,--before model-supplied values, environment from the allow rules only, timeouts and output caps.tool-rest: parsedUrlonly,./..placeholder values rejected or encoded, every placeholder value percent-encoded.failure_reason()in the agent loop shows up to 200 characters of a runner's (remote-controlled) error text in user-visible failure text.Tests
remote_tools::testshas 34 unit tests, plus the core approval/known-answer/key tests, the prompt fence tests, and agent-loop tests for fencing, logging, grounding and the exported spans (with built-in controls).cargo clippy -D warningsclean;bun run test:changedpasses.assessalready refuses), 29 on the keyed approval, fence and log withholding (all caught after fixing a test-filter miss, a fail-open mutant, two bad patterns), and 9 on the review fixes (the ninth: the tool-calls span carrying a remote tool's arguments): the zero key on a read error and on a missing key (both now killed by the new test), span messages not withheld, external history ids grounded, the tag without its label, a changed label, reordered fields, and the provision returning its own key instead of the stored one. All caught.🤖 Generated with Claude Code