Repository navigation
Mark hosted connector results as untrusted for agents - #2206
Conversation
Co-authored-by: kai <[email protected]> Agent-Model: codex/gpt-6-sol/medium
lilyshen0722
left a comment
There was a problem hiding this comment.
Security review at 3bad289 (eng lead). This is the security stamp; Vera gates the code.
What holds:
- The marker can't be steered by the vendor.
untrustedConnectorMarkertakes the catalogue-ownedentry.title(hostedMcpEntryService→entryTitle), never vendor text. On both paths it goes before the result, and the vendor result staysJSON.stringify-encoded after it:- the MCP route returns it as its own content block before the result;
- the native runtime prepends it to the tool message.
So vendor text can't close or rewrite the marker.
- Error paths don't carry vendor bodies around the marker.
safeReasonreturns server codes. Theprovider_errormessages inhostedMcpToolDefinitionsare fixed strings, andprovider_unreachablecarries the network error only, so nothing a vendor returns reaches the agent unmarked through a failure. - The vendor result and the audit classification are untouched, as described.
- Checks: 24 suites touching the broker, MCP route, native runtime, projection and marker pass at this head (309 tests). Lint shows 0 errors on the six changed sources, and no CodeQL alerts are open on the merge ref.
Two scope notes. They don't block this PR; they bound what it settles for #2168:
- Only
hosted-mcpresults are marked. The same broker carries eightgithub-apptool definitions (toolBrokerService.ts,connectionType: 'github-app'), and their results (issue and PR bodies included) are still unmarked. So this PR meets condition 3 of my read-only GitHub ruling only if the GitHub source ships as a hosted-MCP entry. If it uses thegithub-apptools, those results need the same marker before GitHub is offered. - Which runtime "hosted" means here. The broker reaches native-runtime agents (
nativeRuntimeService), which the grants code calls "hosted". The "Run it here" agent (runtimeType: 'hosted') is a Cloudflare Durable Object whose only tool reads pod context: it has no broker and nocommonly_*tools (workers/agent-runtime/src/tools.ts). So conditions 1 (toolset narrowing) and 3 (marker) apply to native-runtime agents. Giving GitHub to the Durable Object agent would be new work, because it has no broker today.
GATE: PASS
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate at 3bad28928d22b74e4bfd9e73d002e40e3872e305 — PASS. This is the row's shape, and the one requirement I most wanted to check — that no vendor text crosses the instruction boundary — holds at the source rather than by assertion.
The marker text is ours, verified where it comes from
untrustedConnectorMarker(title) interpolates exactly one value, and that value is definition.entryTitle ← entry.title. All four catalogue entries declare it as a string literal in our own source: 'Linear' (linear.ts:78), 'Google Calendar' (googleCalendar.ts:48), 'Atlassian' (atlassian.ts:59), 'Airtable' (airtable.ts:51). title: string is required on the entry interface, and nothing anywhere sets it from vendor data — so "Content from undefined" is unreachable and vendor text cannot reach the marker by construction, not merely by test. The route arm then adds the belt-and-braces assertion that content[0].text does not contain the vendor's own text.
The four arms, plus the one I asked for before the build
The row's arms are all present, and the trail invariant I flagged on TASK-211 is in the suite verbatim — mockToolCall.create called with outcome: 'failed', reason: 'upstream_tool_error' for an isError hosted result, with the marker attached and result equal to the vendor payload unchanged. That is the exact thing I said I would gate against, measured at the trail write rather than inferred from "classification untouched". It holds structurally too: recordExecutionResult and recordCall are untouched by this diff; the marker is a field added to the return after the trail row is written.
Refusals stay unmarked (content length 1, carrying grant_revoked), and the MCP route keeps isError: true when the outcome is failed.
Census of every path a hosted result can reach
Three consumers, and I checked each rather than the two the PR describes:
routes/mcpGrants.ts:103— MCP seats. Marked, as a separate leading text block; the vendor block follows byte-identical.grantBrokerProjectionService.dispatchHostedBrokerTool→ native runtime tool message. Marked, prepended with a newline before the vendor JSON.approvalActionService:724— the approved parked call. Its result goes to the card and the room receipt, both human-facing; the seat gets nothing today. So there is no unmarked agent path.executeApprovedToolCallnow returnsuntrustedSourceTitleand nothing consumes it — harmless, worth knowing so nobody reads it as "the approved path is marked".
One cross-link, since I gate it next: #2207 makes approval.resolved wake a seat with payload.content. If that cue ever carried the vendor result rather than a server-composed ending, it becomes a fourth and unmarked path. I will check exactly that there.
The row's "measure first" question has no subject
The instruction was to measure that an extra leading block does not break structuredContent consumers. There are none: structuredContent appears nowhere in the backend, and this route has always flattened the whole reply.result into a single JSON text block before an agent sees it. So the marker-as-separate-block cannot break a consumer that never existed. Non-hosted (GitHub) results correctly get no marker — the spread is gated on connectionType === 'hosted-mcp'.
Measured
Mutations, one variable each, tree restored and re-verified by rev-parse HEAD^{tree}:
- route marker block removed → 2
mcpGrantsarms fail; untrustedSourceTitledropped fromcallToolonly (first of the two occurrences) →finds the hosted tool by name and runs itandrecords a resolved vendor tool error as failed…fail, and the approved path's arm stays green, which is how I know the two returns are covered separately;- native-runtime prepend removed →
a hosted vendor error reaches the model after the marker and marks the run call failedfails.
Focused three suites 61/61. tsc --noEmit -p tsconfig.typescheck.json 0 errors. eslint on the six touched files: 0 errors, 3 warnings. git merge-tree --write-tree clean against main at 8e60a665.
On the full backend suite: my local run reported 63 failures across 10 suites — backfill-hq-members, getAllPods (TASK-151), Agent profile memory activity and similar, none of them related to this diff, while this box was concurrently running a frontend install and suites. CI on this exact SHA is green across 14 checks including Test & Coverage and Service Tests (Tier 1 — real DBs), so I take CI as the instrument here and am not holding on a local number I cannot separate from my own machine's contention.
One note
The marker wording is pinned verbatim in two test files as well as the source. That is the right call for an instruction-boundary string — it should not drift silently — but a future reword touches three files, which is worth knowing before someone tries to improve the sentence.
Written by Vera, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: PASS
…K-267b) A native turn that declares commonly_fetch_url can read one web page through getFromPublicAddress (#2242). The address of a GET reaches its host, so the model never composes one: it may open only an address that appears, as written, in text the turn was given (the prompt, the message it answers, other authors' pod messages, search results, pages already read). Its own words and its own posts never count (webAddressProvenance). A page is third-party text: it reaches the model behind the #2206 marker, cut to 24,000 characters, and narrows the rest of the turn exactly as a search does (in-pod read and post plus lookups). Not offered, and refused at dispatch, in a pod bridged to an external chat. At most 3 pages a turn, counted on the AgentRun as webFetches. A guard refusal reaches the model and does not taint the turn. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
Written by Kai, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015
Change
Proof
TASK-211. Security review requested from CTO; code gate requested from Vera.