Repository navigation
Add the tool-rest runner (remote tools, executor step 3) - #4313
Merged
Merged
Conversation
Sends the one request a tool-rest binding describes: URL built from the parsed template with percent-encoded placeholders, https (http only to loopback), addresses checked after DNS resolution and the connection pinned to the checked address, same-origin redirects only, a credential only to the bound origin, no proxy and no cookies, streamed and capped response returned as text data. The redactor is shared with the tool-cli runner (new redaction module), and the confirmation text now comes from the runner so it can show the resolved address. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…k, wider address blocklist, no response header text in errors, lookups under the timeouts Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4291-rest-runner
branch
from
November 19, 2026 17:34
09c9a61 to
69511f9
Compare
This was referenced Nov 19, 2026
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 3: the
tool-restrunner. This PR changespackages/agent(and installs the runner inpackages/daemon): the user's sign-off stands in for the agent owner's for this build. Everything from thetool-clirunner's reviews applies and is built in from the start.What it adds
packages/agent/src/local_agent/rest_runner.rs(RestRunner), installed in the daemon'sRemoteToolHostbeside thetool-clirunner.ToolRestFields::from_bucketpluscheck_complete; malformed or incomplete fails closed. The method and headers come from the binding, never the model. The URL is built from the template with each{name}placeholder percent-encoded (everything butA-Za-z0-9-._~); a value of.,..or empty is refused (a dot segment would climb out of the path); the result is parsed again and every use (scheme, host, port, request) comes from the parsedUrl, never the stored text. Query parameters go through the URL's own serializer.jsonbody (the arguments no other slot took, capped at 64 KiB). Never a header. Withbody: none, an argument with nowhere to go is refused.httpsalways;httponly forlocalhostor a loopback address; no user information; checked on every hop.localhostor a loopback address (a name resolving to loopback is refused), and a destination named loopback must resolve only to loopback addresses (::ffff:127.xcounts), so plain http to a loopback name can never reach a public address or carry a credential off the machine. Also blocked: 6to42002::/16, Teredo2001::/32,100::/64,3fff::/20,64:ff9b:1::/48,5f00::/16,192.0.0.0/24and192.88.99.0/24. The first checked address is the only one the client's resolver answers with (reqwest'sdns_resolver), so the connection goes to the address that was checked with the original host kept forHostand TLS; the name is resolved once per hop (no rebinding window). A fake resolver in the tests returns a private address on the second call to show it is never used.httpincluded, a private address, user information) is never followed, so no credential or header reaches it. A redirect that would change a non-GETmethod is refused.authreference is resolved only here and goes into one header of the requests to the binding's origin; zeroized; redacted from everything returned, forbasicboth the value and its base64 form. Over https, or over http only to a loopback host. A value with a control character or too short to redact is refused before any request.HTTP_PROXYand friends are ignored on purpose (a credential is never silently routed through a proxy; tested with a proxy variable pointing at a listening server). No cookie store, no content decoding.Content-Lengthis not trusted.text/*,*json*,*xml*, form, javascript); no HTML rendering, nothing decoded as image or archive; no response header is returned (so a credential echoed in a header cannot reach the model); a non-2xx status is an error with a bounded, redacted piece of the body; with no content type, only valid UTF-8.sanitize(andcut) moved out of thetool-clirunner intolocal_agent/redaction.rsand both runners use it, with its exhaustive cut-position tests moved with it. The REST body is sanitized as raw bytes, with the partial-credential tail stripped when the read stopped at the cap.GETwith no credential is confirmed (unchanged); aGETwithoutauthis the only exemption and every SSRF and redirect rule still applies to it. The question is now built by the runner (RemoteToolRunner::confirmation_text, default =destination) so it can resolve first: it shows the method and origin, the resolved address(es), the credential reference (before anything long), then the path and query (cut with a marker), then the body (cut with a marker). If the destination is refused, the user is not asked and the call ends (host-authored refusal, not external).Notes and limits
The system resolver runs on the blocking thread pool, so a lookup that never returns can hold one pool thread for as long as the OS lets it (the call itself is stopped by the timeout).
The credential-over-https check in
runis redundant with the scheme rule (httponly reaches a loopback host); it is kept as a second guard. The user-information check on a redirect target is unobservable (the origin comparison already refuses it); also kept.Redaction is exact-value (and the base64 form for
basic): a URL-encoded or JSON-escaped echo of a value containing",\or+is not caught. The confirm-to-run window is bounded by the check at run time. A model-controlled query argument can carry data to the bound origin, by design.No production confirmer is wired yet, so as with
tool-clionly aGETwith no credential is offered; every othertool-restcall is not offered until the confirmation step lands.The address shown in the question is the one resolved when it was built;
runresolves again and checks again. A name that later points at a different public address is followed; a private one is refused.Redaction replaces exact values: a transformed form of a credential in a body (other than the
basicencoding) is not caught. The credential also sits in theHeaderValuethe HTTP stack holds while the request is in flight.A pure percent-encoding of a value is not a defence against a server that decodes twice; the model-chosen values are data for the bound origin.
The tests start loopback servers; nothing uses the real network. They set
HTTP_PROXY-style variables in the test process (one test).Tests
rest_runnertests (27 first round, 4 in the review round: a loopback name resolving to a public address sends nothing, a credential in aContent-Typeis not echoed, a hanging resolver is stopped by the total timeout and by the confirmation's own bound): placeholder encoding in the parsed URL, dot and empty values, query serializer, method/headers from the binding and the body from leftover arguments, an unmapped argument, a body cap, the three auth schemes with the credential redacted from a body and a response header that echo it, missing/short/CR-LF/control credentials stopping before any request, the address policy table (v4, v6, mapped, NAT64, documentation, shared, loopback by name vslocalhost), a mixed answer refusing the call, names resolving to forbidden addresses, literal forbidden addresses, pinning with a rebinding resolver, the scheme and user-information rules, malformed bindings, same-origin redirects with method and body kept, cross-origin redirects (another port, name, scheme, a private address, protocol-relative, user information) never followed with the other server seeing nothing, the redirect limit and method-changing redirects, the streamed cap closing the connection, a dripping server and the total timeout, a cancelled call closing its connection, content types, non-2xx bodies bounded and redacted, the ignored proxy environment, and the confirmation text (resolved address, credential before a long path or body, a refused destination); one host test for a runner that refuses the destination.cargo clippy -D warningsclean;bun run test:changedpasses.100::/64,3fff,64:ff9b:1::/48,5f00,192.0.0.0/24,192.88.99.0/24; the content type echoed; the confirmation lookup unbounded; the name lookup outside the total timeout). One survived and is untestable here: removing the redaction of the HTTP client's own error text (no way to make a real client error carry the credential); it is defence in depth. Earlier: (run in batches because of the 57-minute slot limit): placeholder values not encoded; dot segments and empty values allowed; an unmapped argument accepted; the request body uncapped; a cross-origin redirect followed; the redirect limit raised; a method-changing redirect followed; the proxy environment used; the connection not pinned; blocked addresses not refused; only the first address checked; private, link-local, mapped, unique-local and loopback-by-name addresses allowed; plain http allowed anywhere; user information allowed; the credential and its base64 form not redacted; binary content returned; the response buffered instead of stream-capped; static headers dropped; an error status returned as success; the error body uncapped; the confirmation missing the resolved address or the credential, or not cutting the body or path; the user asked when the destination is refused (found by the batch, covered by the new host test). Equivalent and not mutated: the client's owntimeoutand the outer total timeout each cover the same bound, so removing one alone changes nothing observable.What remains
tool-mcprunner; the real confirmation wiring (bounded timeout, capped argument display); the enable-and-approve command (add-if-absent key write); thetool_whitelistdecision; fixtures.🤖 Generated with Claude Code