Chat replies can't leak data through images #2073
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#2073
Reference in new issue
Block a user
Why: a chat reply is model-written Markdown, and untrusted content the agent read (a web page, a ticket, an email) can instruct it to embed an external image whose URL carries data in the query string. Today the browser fetches that URL, so data leaves the dashboard inside an image request even when every tool call was permitted. Picture a support ticket that says "include this tracking pixel": the reply renders it and the CRM notes the agent just read go out in the image request.
Today:
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:
Out of scope: #2067 tool discovery, #2068 taint, #2069 memory scopes, #2070 connector credential modes, #2071 admin tools refused in chat, #2072 approval binding, #2074 budgets/rate limits, #2075 audit/revocation/kill-switch, #2078 enforcement on every entry point, #2079 chat-triggered workflow execution contracts, and #2080 disclosure authorization per audience and destination — the destination/audience-wide disclosure policy is #2080; this issue stays the chat markdown renderer plus the dashboard CSP.
Design notes: two layers — the renderer is the primary fix, the CSP header is the browser-side backstop for any markup path that misses it. The server half belongs to modules/dashboard (it owns the SPA responses); the renderer half belongs to ui/src/chat/markdown.ts — change SAFE_SRC so https?:// no longer matches. Sanitizing rendered content tightens disclosure; it is not an authorization control and never grants authority (RFC 4). No migration: stored replies are re-rendered from their text, so old replies with external images stop loading as soon as the code ships. Do not break data:image/ — the model legitimately emits inline charts.
Tests (security boundary, so AGENTS.md requires a test: table cases, fakes, no DB):
Done when: pnpm test and pnpm run typecheck pass in ui/, task check passes at the repo root, and on a running binary: response headers on / show the CSP with img-src 'self' data:; asking chat for a reply containing an external image URL with data in the query string renders no image and devtools shows no request to that origin, while a data:image/ image and a same-origin path still render.
Open questions for the maintainer: None.
Part of #2066.
Fixed in
9af3b2934(pushed to main), both layers as specified.Renderer: SAFE_SRC in ui/src/chat/markdown.ts now keeps only same-origin root-relative paths and data:image/ URLs. http(s)://, protocol-relative //, and /\ (backslash after the leading slash, which browsers read as a remote host) are rejected; unsafe schemes stay rejected. Link handling and loading="lazy" are unchanged, and the shared parser covers task approvals, plans and run transcripts. No proxy, no migration.
Backstop: modules/dashboard sets Content-Security-Policy: img-src 'self' data: (image-only, no other directives) on every non-API response — page, assets, error and no-build responses. The /api/ JSON fallback is unchanged and carries no CSP.
Proof: new table cases failed before the fix (remote https image rendered; CSP header empty on page/asset/read-only/no-build) and pass after; ui pnpm test 127 pass 0 fail, pnpm run typecheck clean, go test ./modules/dashboard ok, full task check exit 0 on this tree. Smoke test with the rebuilt embedded dashboard served on a scratch port: GET / and client routes answer 200 with exactly "img-src 'self' data:" (assets too), /api/nope still answers the JSON 404 with no CSP header; headless Chromium loaded the dashboard normally (title "Dashboard | Archie", app mounted), a remote image URL was blocked by CSP (requestfailed errorText "csp", image never loaded, no bytes left the page), while a data:image/ and a same-origin /favicon.svg both rendered.