Authorization is enforced on every entry point, not only the chat tool router #2078

Open
opened 2026-11-20 09:52:14 +00:00 by sam · 1 comment
Owner

Why: Today the Cedar access chain is consulted in exactly one place: the chat tool router, allowed() in modules/chat/tools.go. Every other way in — the REST API handlers, the webhook intake, trigger-dispatched runs, retries and async workers — authenticates but does not authorize against the policy chain, and judgement is only reached for connector actions inside a run. A person, or a forged webhook, can start a workflow, read runs or manage sources without any Authorize call, so enforcement exists on one path only and the automation platform is the bypass.

Today: internal/platform/httpapi/httpapi.go guard middleware authenticates every API request (session cookie, personal token or bootstrap admin token via Authenticator in modules/governance/auth.go) and marks operations Public, SignedIn or admin-only, with cross-origin protection; beyond that, per-operation authorization is only chat's owner scoping in SQL plus allowed()'s Access.Authorize (governance.Live/Engine in modules/governance) before a tool call. modules/events/events.go Routes/intake serves the webhook intake outside the API and verifies only the source token hash — Engine.AuthorizeDelivery exists in modules/governance/engine.go but the new intake never calls it. Runs are started by dispatch and tick in modules/events with no principal and no Authorize on the workflow resource; modules/runs/runs.go Start checks only that the workflow exists and the input validates, and worker execution (Work/execute) judges connector actions with the workflow name as judgement's principal (rc.request in modules/runs/dry.go) but never calls governance Authorize; retries (deliveries Work backoff, event redispatch, chat settleActions) re-run with chat re-checking allowed() in runApproved but runs not re-authorizing. Everything runs in one process with one database role: internal/app/archie/run.go wires all modules into the single binary and grants the runtime role DML on every module schema (schemas), and owner() merely names the process for run leases — there are no separate workload identities and no service-to-service authentication.

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. All entry points — web, mobile, Slack/Teams, API, retries, async workers, subagents and existing workflow runners — traverse equivalent enforcement; enforcing only at the chat tool router leaves a bypass through the automation platform (RFC 3).
  2. Each entry point authenticates ingress: issuer, audience, expiry, session and tenant binding; channel events additionally verify platform signature, freshness, installation-to-tenant binding, external-user mapping and duplicate event id, and unmapped users or guests get no implicit internal identity; the webhook intake evaluates the delivery policy (AuthorizeDelivery) per source and address, not only the token (RFC 3 stage 1).
  3. Opening a turn checks membership and the send-turn grant and binds initiator, task mode, agent version, session, audience and budgets; expanding to send, mutate, schedule or delegate requires an applicable task grant or trusted UI interaction, never model-inferred consent (RFC 3 stage 2).
  4. Proposed actions are resolved through trusted services — never taking tenant, identity, label or policy facts from the model — and the resolved operation is decided by the enforcement layer, with the executor, not the model, applying the outcome (RFC 3 stages 4–5, RFC 1).
  5. Live authority and preconditions are rechecked at dispatch, on every retry and replay of queued work (RFC 3 stage 6).
  6. Enforcement components run under separate workload identities with authenticated service-to-service communication, and network and datastore permissions make the intended path mandatory: the orchestrator cannot call production SaaS directly, read the credential vault or query the vector store except through its authorization layer (RFC 3).
  7. Subagents inherit no broader action grant, data access, audience, lifetime or budget than their parent task (RFC 3).
  8. Missing or stale facts needed for a decision produce no protected read, disclosure or effect; when a required policy, ACL or account lookup is unavailable, the protected operation does not happen (RFC 1, RFC 6).

Out of scope: tool discovery (#2067), taint (#2068), memory scopes (#2069), connector credential modes (#2070), admin tools refused in chat (#2071), approval binding (#2072), image/CSP (#2073), budgets and rate limits (#2074), audit/revocation/kill-switch (#2075), plus the disclosure-per-audience issue and the chat-triggered-workflows issue filed alongside this one. Beyond those, this issue covers only that every path reaches enforcement — not what the enforcement decides (hard rules, guards, tool manifests).

Design notes: the single authorization seam stays governance.Live.Authorize (modules/governance/live.go, engine.go); entry-point wiring lives in internal/platform/httpapi (authentication middleware), modules/events (intake) and internal/app/archie/run.go (composition root gives every module the authorizer and records the entry surface with WithSource). Seams: httpapi.guard, events.intake, runs.Engine.Start/dispatch, deliveries.Work, chat.Work. Pitfalls: a resumed turn still acts as its owner; never trust model-supplied identity; deny by default; fail closed on ErrChainUnavailable (chat's allowed() already refuses then); background loops must carry an explicit workload principal rather than none (WithoutPrincipal is for the policy loader only). Migration: per-module database roles and grants so the datastore makes the intended path mandatory; no chat-store changes needed.

Tests: security-seam table tests with fakes, no DB:

  • every registered HTTP operation resolves to an (action, resource kind) and a request failing the grant is refused before the handler runs, across each module's routes;
  • webhook intake with a valid token but a delivery-policy denial is refused, and a duplicate event id is counted without re-dispatching;
  • a run started by a trigger, and the same run retried after a worker restart, pass through the same Authorize+judgement path as a chat-initiated action (fake authorizer records both);
  • a delivery retry or approval re-run rechecks live authority and refuses when the grant was revoked mid-flight;
  • a subagent tool call cannot exceed the parent task's grants (fake toolbox enforces);
  • with the policy chain unavailable, no entry point performs a protected operation (fail closed).

Done when: task check passes with the new tests. Manual check on a running binary (task dev): fire a trigger and watch the started run's trail show the same authorization decisions as a chat-initiated action; call a workflow-run or source-management endpoint with a low-privilege token and see it refused; revoke a role while a run is suspended and see its next protected step refused on resume.

Open questions for the maintainer: this binary is a single process today — should "separate workload identities" mean separate database roles and process-level separation per module within the one binary, or splitting services again, and in which deployment; should source webhooks keep token auth plus per-address delivery policy, or move to signed installation events?

Part of #2066.

**Why**: Today the Cedar access chain is consulted in exactly one place: the chat tool router, `allowed()` in `modules/chat/tools.go`. Every other way in — the REST API handlers, the webhook intake, trigger-dispatched runs, retries and async workers — authenticates but does not authorize against the policy chain, and judgement is only reached for connector actions inside a run. A person, or a forged webhook, can start a workflow, read runs or manage sources without any `Authorize` call, so enforcement exists on one path only and the automation platform is the bypass. **Today**: `internal/platform/httpapi/httpapi.go` `guard` middleware authenticates every API request (session cookie, personal token or bootstrap admin token via `Authenticator` in `modules/governance/auth.go`) and marks operations Public, SignedIn or admin-only, with cross-origin protection; beyond that, per-operation authorization is only chat's owner scoping in SQL plus `allowed()`'s `Access.Authorize` (`governance.Live`/`Engine` in `modules/governance`) before a tool call. `modules/events/events.go` `Routes`/`intake` serves the webhook intake outside the API and verifies only the source token hash — `Engine.AuthorizeDelivery` exists in `modules/governance/engine.go` but the new intake never calls it. Runs are started by `dispatch` and `tick` in `modules/events` with no principal and no `Authorize` on the workflow resource; `modules/runs/runs.go` `Start` checks only that the workflow exists and the input validates, and worker execution (`Work`/`execute`) judges connector actions with the workflow name as judgement's principal (`rc.request` in `modules/runs/dry.go`) but never calls governance `Authorize`; retries (deliveries `Work` backoff, event redispatch, chat `settleActions`) re-run with chat re-checking `allowed()` in `runApproved` but runs not re-authorizing. Everything runs in one process with one database role: `internal/app/archie/run.go` wires all modules into the single binary and grants the runtime role DML on every module schema (`schemas`), and `owner()` merely names the process for run leases — there are no separate workload identities and no service-to-service authentication. **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. All entry points — web, mobile, Slack/Teams, API, retries, async workers, subagents and existing workflow runners — traverse equivalent enforcement; enforcing only at the chat tool router leaves a bypass through the automation platform (RFC 3). 2. Each entry point authenticates ingress: issuer, audience, expiry, session and tenant binding; channel events additionally verify platform signature, freshness, installation-to-tenant binding, external-user mapping and duplicate event id, and unmapped users or guests get no implicit internal identity; the webhook intake evaluates the delivery policy (`AuthorizeDelivery`) per source and address, not only the token (RFC 3 stage 1). 3. Opening a turn checks membership and the send-turn grant and binds initiator, task mode, agent version, session, audience and budgets; expanding to send, mutate, schedule or delegate requires an applicable task grant or trusted UI interaction, never model-inferred consent (RFC 3 stage 2). 4. Proposed actions are resolved through trusted services — never taking tenant, identity, label or policy facts from the model — and the resolved operation is decided by the enforcement layer, with the executor, not the model, applying the outcome (RFC 3 stages 4–5, RFC 1). 5. Live authority and preconditions are rechecked at dispatch, on every retry and replay of queued work (RFC 3 stage 6). 6. Enforcement components run under separate workload identities with authenticated service-to-service communication, and network and datastore permissions make the intended path mandatory: the orchestrator cannot call production SaaS directly, read the credential vault or query the vector store except through its authorization layer (RFC 3). 7. Subagents inherit no broader action grant, data access, audience, lifetime or budget than their parent task (RFC 3). 8. Missing or stale facts needed for a decision produce no protected read, disclosure or effect; when a required policy, ACL or account lookup is unavailable, the protected operation does not happen (RFC 1, RFC 6). **Out of scope**: tool discovery (#2067), taint (#2068), memory scopes (#2069), connector credential modes (#2070), admin tools refused in chat (#2071), approval binding (#2072), image/CSP (#2073), budgets and rate limits (#2074), audit/revocation/kill-switch (#2075), plus the disclosure-per-audience issue and the chat-triggered-workflows issue filed alongside this one. Beyond those, this issue covers only that every path reaches enforcement — not what the enforcement decides (hard rules, guards, tool manifests). **Design notes**: the single authorization seam stays `governance.Live.Authorize` (`modules/governance/live.go`, `engine.go`); entry-point wiring lives in `internal/platform/httpapi` (authentication middleware), `modules/events` (intake) and `internal/app/archie/run.go` (composition root gives every module the authorizer and records the entry surface with `WithSource`). Seams: `httpapi.guard`, `events.intake`, `runs.Engine.Start`/`dispatch`, `deliveries.Work`, `chat.Work`. Pitfalls: a resumed turn still acts as its owner; never trust model-supplied identity; deny by default; fail closed on `ErrChainUnavailable` (chat's `allowed()` already refuses then); background loops must carry an explicit workload principal rather than none (`WithoutPrincipal` is for the policy loader only). Migration: per-module database roles and grants so the datastore makes the intended path mandatory; no chat-store changes needed. **Tests**: security-seam table tests with fakes, no DB: - every registered HTTP operation resolves to an (action, resource kind) and a request failing the grant is refused before the handler runs, across each module's routes; - webhook intake with a valid token but a delivery-policy denial is refused, and a duplicate event id is counted without re-dispatching; - a run started by a trigger, and the same run retried after a worker restart, pass through the same `Authorize`+judgement path as a chat-initiated action (fake authorizer records both); - a delivery retry or approval re-run rechecks live authority and refuses when the grant was revoked mid-flight; - a subagent tool call cannot exceed the parent task's grants (fake toolbox enforces); - with the policy chain unavailable, no entry point performs a protected operation (fail closed). **Done when**: `task check` passes with the new tests. Manual check on a running binary (`task dev`): fire a trigger and watch the started run's trail show the same authorization decisions as a chat-initiated action; call a workflow-run or source-management endpoint with a low-privilege token and see it refused; revoke a role while a run is suspended and see its next protected step refused on resume. **Open questions for the maintainer**: this binary is a single process today — should "separate workload identities" mean separate database roles and process-level separation per module within the one binary, or splitting services again, and in which deployment; should source webhooks keep token auth plus per-address delivery policy, or move to signed installation events? Part of #2066.
sam added a new dependency 2026-11-20 09:52:50 +00:00
sam added the featurehigh labels 2026-11-20 09:52:50 +00:00
Author
Owner

Maintainer direction (2026-11-21): not every entry point is gated by authorization, but most (about 90%) are. Working principle: deny by default. Every entry point declares whether it is public, authenticated only, or authorized against the policy chain, and the route table makes the default "authorized". The exemptions are explicit and short:

  • Public: liveness and readiness, the setup and auth-status endpoints, and the dashboard's static assets.
  • Authenticated by their own scheme rather than a person's grant: webhook intake (source verification, #2021) and connector callbacks. These still evaluate the per-source delivery policy before dispatch.
  • Background work (trigger dispatch, retries, deliveries) runs as an explicit workload principal and is authorized like any other caller, never with no principal.

Still open: whether "separate workload identities" means per-module database roles inside the one binary (recommended, and already planned in #2011) or separate processes.

Maintainer direction (2026-11-21): not every entry point is gated by authorization, but most (about 90%) are. Working principle: deny by default. Every entry point declares whether it is public, authenticated only, or authorized against the policy chain, and the route table makes the default "authorized". The exemptions are explicit and short: - Public: liveness and readiness, the setup and auth-status endpoints, and the dashboard's static assets. - Authenticated by their own scheme rather than a person's grant: webhook intake (source verification, #2021) and connector callbacks. These still evaluate the per-source delivery policy before dispatch. - Background work (trigger dispatch, retries, deliveries) runs as an explicit workload principal and is authorized like any other caller, never with no principal. Still open: whether "separate workload identities" means per-module database roles inside the one binary (recommended, and already planned in #2011) or separate processes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#2078