Chat authorizes disclosures per audience and destination, not just tool calls #2080

Open
opened 2026-11-20 09:52:15 +00:00 by sam · 0 comments
Owner

Why: Today chat authorizes only the tool call itself: once allowed() in modules/chat/tools.go passes and judgement runs the action, the reply, every tool output and every approval card can flow anywhere the platform sends it — the composer, every delivering connector channel, the model provider, the browser — with no decision about audience or destination. Picture a support rep asking chat about a customer's case: the rep may read the case, but nothing stops the reply, or its tool traces, being fanned out to a channel, a notification, an export or a provider the case's confidentiality does not permit.

Today: modules/chat/tools.go allowed() checks ActionRun/ActionRead on the connector resource before a tool runs, and guarded() wraps each builtin; that is the only authorization on the reply path. Sessions are per person since cf6108ad1: modules/chat/internal/store/store.go scopes every session and turn query by org and owner, caller() in modules/chat/api.go maps a request to its principal, and serveEvents plus modules/dashboard/stream.go deliver only to the owner's topic — there is no shared or channel chat session in this binary today. But every streamed event (reasoning, deltas, tool outputs via record() in modules/chat/turn.go, approval and action cards) is persisted whole in chat.events — only credential-like parameter keys are redacted by summarizeParameters in modules/chat/parameters.go — and generate() sends the system prompt with all memory notes (memoryBlock) plus up to 20 history turns to the model provider with no processor check. Outbound, modules/deliveries/deliveries.go send() writes each message to the composer and a row per connector that delivers message, and Work() sends to all of them: chat's settled() in modules/chat/actions.go notifies the action result and hold() delivers approval requests, all fanned out to every channel with no destination decision. Rendering is client-side only: ui/src/chat/markdown.ts keeps any https: image URL (SAFE_SRC) which the browser fetches directly (ChatMarkdown.vue), and modules/dashboard/dashboard.go sets no CSP or other security headers; there is no server-side image proxy. Nothing in modules/chat, modules/deliveries or modules/judgement labels data with readers or classification — judgement classes are action-autonomy classes, not data classes.

Source: the revised RFC exported at transcripts/2026-11-20-chat-authorization-rfc-3fa43269.md in sam/archie-product; citations below are RFC section numbers.

Required behaviour:

  1. Every protected release passes the information-flow check in addition to authority and intent-and-execution: inputs and their derivatives may go to a processor, destination and audience only if data-flow policy permits it (RFC 1).
  2. The destination is modeled, not just current participants: guests, federation, public links, future joiners with history access, channel exports, notifications and provider retention are all part of the destination decision before anything is posted or sent (RFC 4).
  3. Where a confidential answer would go to a shared audience, the default options are view-privately or cancel; a channel-safe answer is offered only if generated from inputs independently authorized for that channel, or through an explicitly approved release; sharing or declassification is a separate business action with its own authority, destination policy and audit (RFC 4).
  4. Actor and audience are decided separately: private results route to the asking person through an authenticated private surface; the actor's rights are never reduced to those of the least-privileged audience member (RFC 4).
  5. A private result, tool trace or approval card is never first persisted as a shared message and then hidden client-side; audience restrictions are enforced at storage, fetch, push and reconnect (RFC 4).
  6. Confidentiality is tracked separately from instruction trust; no domain allowlist or clean flag makes content authoritative (RFC 4).
  7. Derivatives — messages, summaries, retrieved chunks, generated files, cached results — carry tenant, source references, applicable readers/classification, provenance and retention, and a synthesis inherits the restrictions of its inputs unless a trusted transformation establishes otherwise; no single scalar high-water mark for disjoint reader sets (RFC 4).
  8. All outbound paths are sinks: search queries, GET parameters, navigation, remote tools, model calls, telemetry, generated links and image previews can disclose data even when labeled read; automatic remote fetches and unfurls are disabled, rendered content is sanitized, and a server-side image proxy must not fetch arbitrary model-generated URLs (RFC 4).
  9. Results are released sink by sink: rows and fields are filtered, lineage and classification applied, and each sink — next model call, private UI, channel, attachment, notification, memory, log — is authorized before release; protected tokens are never streamed to a client and inspected afterward (RFC 3 stage 7).
  10. The model or embedding provider is authorized as a processor of the assembled context before it is sent; prompt, provider thread state, traces and provider caches count as data transfers (RFC 3 stage 3).
  11. The decision record carries the destination, so each release decision names where the data went (RFC 6).

Out of scope: tool discovery filtering (#2067), taint (#2068), memory scopes (#2069), connector credential modes (#2070), admin tools refused in chat (#2071), approval binding (#2072), CSP headers and image rendering policy (#2073 — sink authorization for image fetches is here, the header and rendering work is there), budgets and rate limits (#2074), audit/revocation/kill-switch (#2075), plus the enforcement-parity issue and the chat-triggered-workflows issue filed alongside this one. Beyond those, this issue does not cover ingress authentication of channels, the workflow step vocabulary, or judgement guard internals.

Design notes: owning modules: modules/chat owns the turn and its release path (turn.go, actions.go, api.go, internal/store), modules/deliveries owns the outbound sinks, modules/dashboard owns serving and streams; the provider-processor check belongs in generate() in turn.go. Seams: record()/serveEvents for transcript audience, settled() → Notifier.Notify and Approver.Ask for channel fan-out, deliveries.send per-channel rows, summarizeParameters/toolCall for what is stored. Pitfalls: a resumed turn still acts as its owner; never take identity, audience or classification facts from the model; deny by default and fail closed when a policy, ACL or lookup is unavailable (as allowed() already does on ErrChainUnavailable); a private result must not land in a shared transcript first. Migration: chat.events and deliveries rows need audience/classification columns owned by their modules' schemas.

Tests: security-seam table tests with fakes, no DB, alongside modules/chat/access_test.go:

  • a release decision with an unavailable data-flow policy refuses every sink (fail closed), not just the channel;
  • a permitted tool call whose output carries a confidential source is refused at the channel sink while the private UI sink is allowed;
  • approval requests and action-result notifications are not fanned out to a delivering channel the content's classification does not cover;
  • a stored private event is invisible to a different principal at fetch, stream and reconnect (storage-enforced, not client-hidden);
  • a derivative summary inherits the disjoint reader sets of its inputs rather than a single high-water mark;
  • context is not sent to the model provider when the provider is not an authorized processor of it;
  • a model-generated image URL is not fetched server-side unless it passes the proxy's allowlist.

Done when: task check passes with the new tests. Manual check on a running binary (task dev): ask chat for something confidential, then try to send the answer to a channel — the channel receives nothing (or an access-controlled link with a non-sensitive title and no preview), the private reply appears only in the owner's conversation and event stream, and a second signed-in user streaming or replaying the turn's events sees nothing.

Open questions for the maintainer: does the product intend any shared or channel chat surface in this binary (the composer is currently the only shared sink), or is chat private-only with deliveries as the outbound path — RFC 4's removal of "post publicly" assumes a shared-channel warning exists somewhere; which model providers meet the retention and processor policy, and is that a per-tenant setting; is a server-side image proxy in scope here or under the image/CSP issue?

Part of #2066.

**Why**: Today chat authorizes only the tool call itself: once `allowed()` in `modules/chat/tools.go` passes and judgement runs the action, the reply, every tool output and every approval card can flow anywhere the platform sends it — the composer, every delivering connector channel, the model provider, the browser — with no decision about audience or destination. Picture a support rep asking chat about a customer's case: the rep may read the case, but nothing stops the reply, or its tool traces, being fanned out to a channel, a notification, an export or a provider the case's confidentiality does not permit. **Today**: `modules/chat/tools.go` `allowed()` checks `ActionRun`/`ActionRead` on the connector resource before a tool runs, and `guarded()` wraps each builtin; that is the only authorization on the reply path. Sessions are per person since cf6108ad1: `modules/chat/internal/store/store.go` scopes every session and turn query by org and owner, `caller()` in `modules/chat/api.go` maps a request to its principal, and `serveEvents` plus `modules/dashboard/stream.go` deliver only to the owner's topic — there is no shared or channel chat session in this binary today. But every streamed event (reasoning, deltas, tool outputs via `record()` in `modules/chat/turn.go`, approval and action cards) is persisted whole in `chat.events` — only credential-like parameter keys are redacted by `summarizeParameters` in `modules/chat/parameters.go` — and `generate()` sends the system prompt with all memory notes (`memoryBlock`) plus up to 20 history turns to the model provider with no processor check. Outbound, `modules/deliveries/deliveries.go` `send()` writes each message to the composer and a row per connector that delivers `message`, and `Work()` sends to all of them: chat's `settled()` in `modules/chat/actions.go` notifies the action result and `hold()` delivers approval requests, all fanned out to every channel with no destination decision. Rendering is client-side only: `ui/src/chat/markdown.ts` keeps any `https:` image URL (`SAFE_SRC`) which the browser fetches directly (`ChatMarkdown.vue`), and `modules/dashboard/dashboard.go` sets no CSP or other security headers; there is no server-side image proxy. Nothing in `modules/chat`, `modules/deliveries` or `modules/judgement` labels data with readers or classification — judgement classes are action-autonomy classes, not data classes. **Source**: the revised RFC exported at transcripts/2026-11-20-chat-authorization-rfc-3fa43269.md in sam/archie-product; citations below are RFC section numbers. **Required behaviour**: 1. Every protected release passes the information-flow check in addition to authority and intent-and-execution: inputs and their derivatives may go to a processor, destination and audience only if data-flow policy permits it (RFC 1). 2. The destination is modeled, not just current participants: guests, federation, public links, future joiners with history access, channel exports, notifications and provider retention are all part of the destination decision before anything is posted or sent (RFC 4). 3. Where a confidential answer would go to a shared audience, the default options are view-privately or cancel; a channel-safe answer is offered only if generated from inputs independently authorized for that channel, or through an explicitly approved release; sharing or declassification is a separate business action with its own authority, destination policy and audit (RFC 4). 4. Actor and audience are decided separately: private results route to the asking person through an authenticated private surface; the actor's rights are never reduced to those of the least-privileged audience member (RFC 4). 5. A private result, tool trace or approval card is never first persisted as a shared message and then hidden client-side; audience restrictions are enforced at storage, fetch, push and reconnect (RFC 4). 6. Confidentiality is tracked separately from instruction trust; no domain allowlist or clean flag makes content authoritative (RFC 4). 7. Derivatives — messages, summaries, retrieved chunks, generated files, cached results — carry tenant, source references, applicable readers/classification, provenance and retention, and a synthesis inherits the restrictions of its inputs unless a trusted transformation establishes otherwise; no single scalar high-water mark for disjoint reader sets (RFC 4). 8. All outbound paths are sinks: search queries, GET parameters, navigation, remote tools, model calls, telemetry, generated links and image previews can disclose data even when labeled read; automatic remote fetches and unfurls are disabled, rendered content is sanitized, and a server-side image proxy must not fetch arbitrary model-generated URLs (RFC 4). 9. Results are released sink by sink: rows and fields are filtered, lineage and classification applied, and each sink — next model call, private UI, channel, attachment, notification, memory, log — is authorized before release; protected tokens are never streamed to a client and inspected afterward (RFC 3 stage 7). 10. The model or embedding provider is authorized as a processor of the assembled context before it is sent; prompt, provider thread state, traces and provider caches count as data transfers (RFC 3 stage 3). 11. The decision record carries the destination, so each release decision names where the data went (RFC 6). **Out of scope**: tool discovery filtering (#2067), taint (#2068), memory scopes (#2069), connector credential modes (#2070), admin tools refused in chat (#2071), approval binding (#2072), CSP headers and image rendering policy (#2073 — sink authorization for image fetches is here, the header and rendering work is there), budgets and rate limits (#2074), audit/revocation/kill-switch (#2075), plus the enforcement-parity issue and the chat-triggered-workflows issue filed alongside this one. Beyond those, this issue does not cover ingress authentication of channels, the workflow step vocabulary, or judgement guard internals. **Design notes**: owning modules: `modules/chat` owns the turn and its release path (`turn.go`, `actions.go`, `api.go`, `internal/store`), `modules/deliveries` owns the outbound sinks, `modules/dashboard` owns serving and streams; the provider-processor check belongs in `generate()` in `turn.go`. Seams: `record()`/`serveEvents` for transcript audience, `settled()` → `Notifier.Notify` and `Approver.Ask` for channel fan-out, `deliveries.send` per-channel rows, `summarizeParameters`/`toolCall` for what is stored. Pitfalls: a resumed turn still acts as its owner; never take identity, audience or classification facts from the model; deny by default and fail closed when a policy, ACL or lookup is unavailable (as `allowed()` already does on `ErrChainUnavailable`); a private result must not land in a shared transcript first. Migration: `chat.events` and deliveries rows need audience/classification columns owned by their modules' schemas. **Tests**: security-seam table tests with fakes, no DB, alongside `modules/chat/access_test.go`: - a release decision with an unavailable data-flow policy refuses every sink (fail closed), not just the channel; - a permitted tool call whose output carries a confidential source is refused at the channel sink while the private UI sink is allowed; - approval requests and action-result notifications are not fanned out to a delivering channel the content's classification does not cover; - a stored private event is invisible to a different principal at fetch, stream and reconnect (storage-enforced, not client-hidden); - a derivative summary inherits the disjoint reader sets of its inputs rather than a single high-water mark; - context is not sent to the model provider when the provider is not an authorized processor of it; - a model-generated image URL is not fetched server-side unless it passes the proxy's allowlist. **Done when**: `task check` passes with the new tests. Manual check on a running binary (`task dev`): ask chat for something confidential, then try to send the answer to a channel — the channel receives nothing (or an access-controlled link with a non-sensitive title and no preview), the private reply appears only in the owner's conversation and event stream, and a second signed-in user streaming or replaying the turn's events sees nothing. **Open questions for the maintainer**: does the product intend any shared or channel chat surface in this binary (the composer is currently the only shared sink), or is chat private-only with deliveries as the outbound path — RFC 4's removal of "post publicly" assumes a shared-channel warning exists somewhere; which model providers meet the retention and processor policy, and is that a per-tenant setting; is a server-side image proxy in scope here or under the image/CSP issue? Part of #2066.
sam added the featurehigh labels 2026-11-20 09:52:50 +00:00
sam added a new dependency 2026-11-20 09:52:50 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#2080