ADR-0028: Mutating owner requests carry a header and a same-origin check; the worker's browser cannot reach the web UI or Postgres
Amends ADR-0014 and ADR-0026 (the Playwright origin list) and the "no login, the tailnet is the boundary" reading of ADR-0016.
Context and Problem Statement
The owner API has no login. The UI check's browser may open any loopback port (ADR-0026: the app's ports are chosen by the plan), and only the engine port was blocked. The web UI (vite preview on 127.0.0.1:5180) proxies the whole /api, so a prompt-injected worker could navigate there and click Approve on its own permission cards, and the page JavaScript of the app under test could fire body-less cross-origin POSTs (/api/usage/reset, cancel, hold, retry, stop, archive, send-now) at it with mode: 'no-cors', which needs no preflight.
Decision
- Wider block list. Playwright's
--blocked-originsholds the engine port, the web UI port (WEB_UI_PORT = 5180, a constant inrun-files.tsbecause the engine's config does not know it) and the Postgres port (taken fromDATABASE_URL, passed asRunContext.protectedPorts), on127.0.0.1andlocalhost. Every other loopback port stays reachable (ADR-0026); the dev server refuses ports already in use, so a plan cannot pick these. - Owner request guard. A Fastify
onRequesthook (presentation/http/owner-guard.ts) answers403 forbiddento any POST, PUT, PATCH or DELETE that lacksX-Jarvis-Owner: 1, and to any that carries anOriginwhose host differs from the request'sHostand is not listed inJARVIS_ALLOWED_ORIGINS(comma-separated, for a dev UI proxied to a remote engine, wherechangeOriginrewritesHost). A cross-origin page cannot add the custom header without a preflight, and the API answers none. Reads and the SSE stream are not guarded. - Exempt:
/api/agent/*, which authenticates withAuthorization: Bearer <run token>. - The web client sends
X-Jarvis-Owner: 1on every request. Scripts that mutate the API (for example a cron callingPOST /api/threads) must send it too.
Consequences
- A prompt-injected browser can still read the web UI if it were reachable; it no longer is, and what it could POST from a page is refused.
- This is a brake, not authentication: anything on the machine that can set a header still gets through. Real owner auth stays the tailnet boundary.