Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tainted-destinations-ask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@schlessera/brain-ui-sdk": minor
"@schlessera/brain-ui-server": minor
---

A tainted interactive session now asks before reaching a new destination instead of refusing it silently (#3430). When a governed or strict turn behind the egress proxy connects to a host outside its `taint.egress.allow` list and the hosts the session already contacted, the user sees a `Network` permission card naming the host, what tainted the session, and that allowing it admits the host for the rest of the session. Allowing admits the connection and every later one to that host in the session; declining refuses it with a 403 whose status text and body tell the tool the user declined. Voice turns still refuse without a card, autonomous turns are unchanged, and `deny` and `allowlist` egress modes still refuse first. `startEgressProxy`'s `taint` option gains an optional `approve` callback.
45 changes: 39 additions & 6 deletions docs/decisions/governed-writable-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@ reports which applies as `governed.egress`. Making the relay work without
managed storage is follow-up work. Each connection is recorded as a governance event, and a recording
failure ends the turn. Without a governance recorder the policy still applies
and only the records are absent (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:60-166`). The note says egress is
`packages/ui-server/src/brain/turn-egress.ts:80-213`). The note says egress is
recorded only when the backend actually routed the worker through the proxy.
API-key Claude profiles (2026-10-22) and pi turns (2026-10-23) are routed
too. A pi turn whose credential the relay cannot carry is refused rather than
Expand Down Expand Up @@ -3738,7 +3738,7 @@ outward host skips the card only while every classified call in progress is a
visible read, or an approved outward action that names that host. A GitHub
write names the GitHub API hosts, and a push or HTTP write names its target's
host. Any unknown or opaque call in progress withholds the exception
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:36-58`).
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:56-78`).
A background process left by an earlier call can still connect inside such a
window; the proxy records it either way.

Expand Down Expand Up @@ -3783,7 +3783,9 @@ Taint is sticky for the session, because that content stays in the context
window. A tainted session runs under tighter rules:

- egress switches to the policy's `taint.egress` allow-list, which by default
is the hosts already used in the session plus the inference relay;
is the hosts already used in the session plus the inference relay (an
interactive turn asks before any other host since 2026-11-03, see
[below](#tainted-destinations-ask));
- every outward action asks, even if `outward.allow` would allow it;
- writes to steering artifacts are flagged in the journal (below).

Expand Down Expand Up @@ -3829,9 +3831,10 @@ first byte. Once the session is tainted, a new connection must pass the
ordinary egress rules and also match `taint.egress.allow` or a host the
session's proxies already admitted (a record with charged bytes; the proxy
charges only after admission); otherwise it is refused and recorded as an
`egress_denial` with reason `taint_allowlist`. The taint list narrows and never
widens: deny and `allowlist` mode still apply first (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:60-166`). Hosts without managed
`egress_denial` with reason `taint_allowlist` (an interactive turn asks first
since 2026-11-03, see [below](#tainted-destinations-ask)). The taint list
narrows and never widens: deny and `allowlist` mode still apply first (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:80-213`). Hosts without managed
native storage have no proxy, so the Bash classifier remains their shell rule
and nothing narrows their egress.

Expand Down Expand Up @@ -3864,6 +3867,36 @@ workspaces/x/README`, or a marked file) does not taint. Path detection is not
extended to shell arguments, because parsing them is the shell classifier
this ruling removes. File tools reading the same path still taint.

<a id="tainted-destinations-ask"></a>

**Tainted destinations ask — 2026-11-03
([#3430](https://github.com/schlessera/brain-kit/issues/3430)).** This
supersedes the refusal in the implemented note above for interactive turns.
The silent, final refusal read as an outage: the agent saw `proxy refused the
connection` or a bare 403, the user was never asked, and the only workaround
was a hostname-wide `taint.egress.allow`. Now, when a tainted interactive
turn's connection passes deny, `allowlist` mode and the byte ceiling but
matches neither `taint.egress.allow` nor a contacted host, the proxy asks
through the turn's tool-permission card (`toolName: "Network"`, `kind:
"command"`, never remembered as a tool grant) before refusing
(`const narrowing`, `packages/ui-sdk/src/server/egress-proxy.ts:148-153`). The
card names the destination, the session's first taint source and the
consequence of allowing it
(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:35-40`).
Concurrent connections to the same host share one card. An allowed
connection's admission adds its host to the turn's contacted hosts, and its
charged `egress_connection` record carries the host into the session's later
turns, so it is not asked for again; a different host still asks
(`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:153-164`).
A decline refuses: the record stays an `egress_denial` with reason
`taint_allowlist`, and the 403 carries a short reason the tool can print (`function refusal`,
`packages/ui-sdk/src/server/egress-proxy.ts:70-74`). Stopping the turn while the
card is pending cancels the connection, and a late allow admits nothing. Voice turns, which have no
grant surface, and autonomous turns, which have no turn proxy, refuse without
a card as before; deny and `allowlist` mode still refuse first. Maintainer
ruling A on #3430; B (ask only for reads) and C (keep refusing with an
after-the-fact notice) were rejected.

**Files the user marks untrusted — 2026-11-02
([#2673](https://github.com/schlessera/brain-kit/issues/2673)).** A user can
mark a brain file untrusted from Files, and the recorder above then treats an
Expand Down
8 changes: 6 additions & 2 deletions docs/hosting/agent-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The explicitly prepared ordinary egress proxy follows that same helper
selection. Its directory and socket remain owned by the server and use its
shared primary group, with exact `0750`/`0660` modes; a setgid temporary parent
cannot choose another IPC group (`const separateIdentity`,
`packages/ui-sdk/src/server/egress-proxy.ts:77-83`). Without a helper they retain
`packages/ui-sdk/src/server/egress-proxy.ts:90-96`). Without a helper they retain
owner-only `0700`/`0600` modes. Before mounting the proxy, the launcher checks
canonical paths, server ownership, the expected helper group, exact modes and
socket type. Missing entries, symlinks and widened permissions refuse before
Expand Down Expand Up @@ -1618,7 +1618,11 @@ A tainted session's outward actions all ask, whatever `outward.allow` says,
on both backends. On the turn proxy, every admitted connection other than the
inference relay taints the session too, and a tainted session's new
connections reach only `taint.egress.allow` and hosts its proxies already
admitted. Refusals are `egress_denial` events with reason `taint_allowlist`.
admitted. In an interactive turn, a connection to any other host first shows
a permission card naming the host and what tainted the session; allowing it
admits that host for the rest of the session (#3430). Voice turns refuse
without a card. Refusals, including a declined card, are `egress_denial`
events with reason `taint_allowlist`.
Without the proxy (hosts without managed native storage) nothing narrows
egress, and the capabilities note says so. On a turn behind the proxy, the Bash
classifier above is off: the proxy's connection taint is the shell signal, so
Expand Down
2 changes: 1 addition & 1 deletion docs/http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ read by any authenticated principal.
| `state_room_warning` | 1 | `usedBytes`, `allowanceBytes`, `observedAt` | A resumed conversation's measured state reached its existing 75% warning threshold. The numbers and Unix-millisecond timestamp are the same observation sent with its result and history. One quiet event per session, backend and allowance; it does not change admission or start a continuation. |
| `budget_block` | 1 | `scope`, `unit`, `limit`, `observed`, `source`, `stage` | A block limit was reached. `stage` is `admission`, `mid_turn` or `sdk_backstop`. |
| `scope_cap` | 1 | `cap`, `limit`, `observed`, `overshoot`, `frozen`, `outcome`, `source` | A per-turn cap was reached. `cap` is `files_changed`, `minutes`, `tool_calls`, `free_space_floor` or `turn_bytes`; `overshoot` is how far past the cap the turn went, in the cap's unit; `outcome` is `paused`, `continued`, `stopped`, `voice_stopped` or `turn_ended`. `paused` records the confirmed freeze before the user decides; retained turn scope receipts record its eventual decision or interruption. A free-space overshoot is the measured deficit below its floor. |
| `egress_denial` | 1 | `host`, `port`, `method`, `reason`, `bytes` | The egress proxy refused a connection. `method` is set for plain HTTP; `reason` is `denied_host`, `not_allowlisted`, `byte_cap` or `taint_allowlist`. |
| `egress_denial` | 1 | `host`, `port`, `method`, `reason`, `bytes` | The egress proxy refused a connection. `method` is set for plain HTTP; `reason` is `denied_host`, `not_allowlisted`, `byte_cap` or `taint_allowlist`; `taint_allowlist` includes a tainted destination the user declined (#3430). |
| `strict_fallback` | 1 | `path`, `reason` | A turn ran under `strict` instead of `governed` because a protected path is a `symlink`, a `hardlink` or a `mount_point`. |
| `revert_conflict` | 1 | `conflicts`, `restored` | A revert skipped paths that changed after the reverted turn. Each conflict is `{ path, state }`, with `state` one of `changed`, `deleted`, `created` or `type_changed`; `restored` counts the paths it did restore. |
| `outward_action` | 1 | `tool`, `input`, `inputTruncated`, `action`, `target`, `historyRewrite`, `tainted`, `decision`, `rule` | An action outside the brain in the user's name, allowed or not. `action` is `git_push`, `gh_write`, `mcp_tool`, `http_write` or `outward_host_connect`; `decision` is `policy_allowed`, `approved`, `declined` or `refused`; `rule` is the matching `outward.allow` rule or `null`. |
Expand Down
13 changes: 13 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ same-commit update of the index or relevant authoritative component. How they ar

The reasoning is in [decisions/contract-versioning.md](decisions/contract-versioning.md).

## Tainted destinations ask (additive, #3430)

In a tainted interactive session behind the turn egress proxy, a connection to
a host outside the session's taint allow-list and contacted hosts raises the
existing tool-permission request (`toolName: "Network"`, `kind: "command"`)
instead of being refused at once. An allow admits that host for the rest of
the session. The request shape, the governance event kinds and the
`egress_denial` reasons are unchanged; `egress_connection` gains the `reason`
value `taint_not_approved` for a declined card. Voice and
autonomous turns keep refusing without a request. See the
[governance events component](integration-contract/http.md#tainted-destinations-ask-additive-3430)
and the [decision](decisions/governed-writable-workers.md#tainted-destinations-ask).

## Shell taint behind the egress proxy (breaking before 1.0, #3429)

On a turn whose worker runs behind the turn egress proxy
Expand Down
16 changes: 16 additions & 0 deletions docs/integration-contract/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,22 @@ turn behind the turn egress proxy, `taint` is no longer recorded with
the proxy still records both. The payload shape and version are unchanged, and
stored events keep their recorded sources.

<a id="tainted-destinations-ask-additive-3430"></a>

**Tainted destinations ask (additive, #3430).** In a tainted interactive turn
behind the proxy, a connection to a host outside `taint.egress.allow` and the
session's contacted hosts now raises the existing tool-permission request
before it is refused: `toolName: "Network"`, `kind: "command"`, `input` of
`{ host, port, method, target }` with `target` as `host:port`, and a
`description` naming what tainted the session and what allowing does. No
request field, kind or card variant is added. An allowed connection records
`egress_connection` as any admitted one does; a declined one records
`egress_connection` with `reason: "taint_not_approved"` and the existing
`egress_denial` with `reason: "taint_allowlist"`. A turn stopped while the card
is pending records the connection as `cancelled` with `turn_cancelled`, as any
connection its turn stops. Voice turns refuse without a request, as before,
with `reason: "taint_not_allowed"`.

The kinds and each kind's payload are versioned separately. A payload change
that is not purely additive bumps that kind's `schemaVersion`, and stored
events keep the version they were written with, so a new version or a new
Expand Down
32 changes: 32 additions & 0 deletions packages/ui-react/tests/render/approval-effect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,35 @@ describe("the effect of a confirmed command, on the card", () => {
expect(view.container.textContent ?? "").not.toContain(EFFECT);
});
});

// A tainted session's new destination asks (#3430). The host sends a
// `Network` command approval whose input carries the destination as `target`
// and whose description names what tainted the session and what allowing
// does; both cards draw them, from the existing request shape.
describe("a tainted session's destination card", () => {
const COPY = "This session fetched a web page, so content you did not write may be steering it. "
+ "Allow it to connect to aeaea.example:443? Allowing lets it send data to aeaea.example for the rest of this session without asking again.";
const network = pending({
id: "net-1",
name: "Network",
input: { host: "aeaea.example", port: 443, method: "CONNECT", target: "aeaea.example:443" },
inputJson: '{"host":"aeaea.example","port":443,"method":"CONNECT","target":"aeaea.example:443"}',
approvalDescription: COPY,
});

test("the Actions-pane card names the destination, the taint source and the consequence", () => {
const view = render(<ApprovalCard tool={network} origin="this conversation" keys={false} onDecide={() => {}} />);
const card = view.getByRole("group", { name: "Approval: Network" });
expect(card.textContent, "TAINTED_CARD_DESTINATION").toContain("aeaea.example:443");
expect(card.textContent, "TAINTED_CARD_SOURCE").toContain("This session fetched a web page");
expect(card.textContent, "TAINTED_CARD_CONSEQUENCE").toContain("for the rest of this session");
});

test("the transcript's card says the same and offers no always-allow", () => {
const view = render(<ToolCallTimeline toolCalls={[network]} onApproval={() => {}} />);
const panel = view.container.textContent ?? "";
expect(panel).toContain("aeaea.example:443");
expect(panel).toContain(COPY);
expect(panel.toLowerCase(), "TAINTED_CARD_NOT_REMEMBERED").not.toContain("always");
});
});
Loading
Loading