Repository navigation
Description
Status (2026-10-05)
Unblocked. The harness-side prerequisite has landed in rossoctl/moca — the harness now sends a
per-request subject and carries an inert placeholder (sh-placeholder-<subject>) instead of a real
key, and placeholder mode is preferred whenever an injector is configured. What remains is entirely
Cortex-side. See the breakdown comment below for the ordered work; steps
1–4 there need nothing further from MOCA.
What this is
Give a tracked home to the deferred per-user half of Z5. This is not a new design: docs/specs/2026-06-19-m13-generalized-credentialed-egress-design.md already specifies generalized credentialed egress, and docs/specs/README.md records that RC1 implements "a static single-tenant slice of Z5 (per-user / RFC 8693 deferred)". This issue is that deferred half.
Please read Z5 and ADR-0006 as the design; this issue records the seam and the open tension rather than restating them.
Why now
rossoctl/moca (formerly rossoctl/serverless-harness) split its multi-session work (moca#220) into three slices. Two are harness-local; the third is this one, tracked on the MOCA side by the stub moca#241. The harness slice — moca#239 — makes the harness send a per-request subject and carry an inert placeholder instead of a real key. Nothing consumes that subject until static-inject can resolve a credential from it.
Until then the harness slice makes the system tenancy-neutral, not multi-tenant safe. That boundary should not be advertised as closed until this lands. MOCA's multi-user isolation design §2.4 cites this issue by number as the evidence that an unmodified Cortex cannot provide per-user egress.
Goal
ADR-0006's (subject ⊕ destination) → credential resolution. Today static-inject resolves by destination host (key_by: host) or a static key (key_by: static, ADR-0026) — one credential per deployment.
The seam
core/plugins/staticinject/resolver.go:17-22 defines:
Resolve(ctx context.Context, key string) (value string, ok bool)implemented only by MapResolver (:28-34, tests/dev) and a secret_dir-style FileResolver (:39-59, path-contained, fails closed). Per-subject resolution makes that key identity-derived rather than destination-derived. FileResolver already maps one key to one credential file, so the resolver layer needs no change — only a new key_by mode and a source for the identity.
pipeline.Context already carries the identity: core/pipeline/context.go:26 defines an Identity interface (Subject(), ClientID(), Scopes()) and :152 holds the field, populated by whichever auth plugin ran. No plugin currently reads it.
Prior art in this repo
core/plugins/tokenbroker/plugin.go:281-294 already extracts a subject token from the inbound Authorization: Bearer header and exchanges it via client.AcquireToken. token-exchange implements RFC 8693 with a result cache. The exchange machinery exists; what is missing is static-inject keying on a caller identity.
Design tension — settled
The two plugins disagreed about which header carries the subject:
- P5 deliberately keeps inbound
Authorizationfree for caller authentication, carrying the placeholder on egressAuthorization: Bearer <placeholder>with the subject on a separateX-SH-Subject. tokenbrokerexpects the subject token on the hop'sAuthorization.
Resolution: neither — the identity must come from the connection, not the request. Keying resolution on the inbound placeholder is a privilege escalation: sh-placeholder-<subject> is predictable and arrives from a model-influenced workload, so any sandbox could present another user's placeholder and receive their real credential. Likewise static-inject's existing Placeholder field is a single literal equality gate, not a lookup key, so against per-subject placeholders it yields either 401 static-inject.placeholder-mismatch for every subject but one, or (gate unset) one shared host-keyed credential and no isolation. MOCA's invariant I3 states it directly: caller identity comes from the connection, never the request.
This is what makes items 3 and 4 of the breakdown (non-TCP listener; identity carried from a CONNECT into the requests bridged inside the tunnel) part of the same issue rather than separate conveniences.
Also missing
Beyond resolution itself, per MOCA's §2.4 capability survey: no audit event is recorded on a successful injection (Z5 specifies the shape), and Cortex listens only on TCP — a Unix-socket listener is what the owed §12.2 decision on moca#277 asks for by name.
Already shipped — not part of this ask
13d80627— configurableinject_headerforx-api-key.adf5d2af— fail closed on an empty resolved credential.
History
Originally opened blocked on moca#239 ("the injector cannot key on a subject the harness does not yet send"). That prerequisite has since landed; the blocked label is removed. Paths in this issue were updated after afb49e9f flattened authbridge/ into the repo root (authbridge/authlib/plugins/ → core/plugins/). Older harness specs and ADR-0032 may still name this repo kagenti-extensions, which redirects here — worth correcting on both sides as those docs are touched.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
pdettori commentedon Sep 28, 2026
Rescope proposal: from "per-subject
static-inject" to a connection-bound caller-identity contractThe deployment this issue was written for has changed, and so has the right shape of the ask.
What changed on the harness side
serverless-harnessis being renamed MOCA and is moving off Kubernetes (its RA1 plan): the primary deployment becomes a supervisor with long-lived worker processes that each multiplex many users' sessions (P6), and Firecracker microVM sandboxes with no network device, whose egress reaches the host only over vsock (P4 / P4.1). One egress proxy per host is shared by every VM on it.In that topology the original framing no longer fits. Both options in the "design tension" above — a subject in
X-SH-Subject, or a subject token on the hop'sAuthorization— are asserted by the caller, and a proxy shared across users must not select a credential on anything the caller can assert (Z1's forbidden "shared identity + subject header" pattern). The tension is resolved by neither: identity has to come from how the connection arrived, established by a trusted host-side component.What MOCA is doing about it
To keep this off MOCA's critical path, MOCA will ship a small, single-purpose Go proxy of its own first (
moca-egress). This issue therefore no longer blocks MOCA, and is no longer blocked by serverless-harness#239. It becomes: Cortex implements the MOCA proxy contract, and replacesmoca-egressonce MOCA needs capabilities only Cortex has (IBAC, SPARC, OPA policy, budgets,abctlobservability).MOCA is keeping that swap cheap on its side: the control plane's credential endpoint is RFC 8693-shaped (so
token-exchangecan talk to it), audit events follow Z5's shape, and the contract ships with a conformance suite thatmoca-egresspasses first and a Cortex implementation would pass before replacing it.Proposed new scope for this issue
token-exchange(or a sibling plugin) uses that verified identity as thesubject_token, rather than the inner request'sAuthorizationbearer; the inert placeholder is overwritten regardless of its value; the injected header is configurable (e.g.x-api-keyfor Anthropic, not onlyAuthorization: Bearer); results cached per (identity, audience).via,host,method,path,subject, caller identity), with query strings redacted.Suggested retitle, if the author agrees: "Connection-bound caller identity and identity-keyed credential resolution (MOCA proxy contract)" — and the
blockedlabel can likely come off. I have not edited the title, body or labels.cwiklik commentedon Oct 5, 2026
Yes — this is still real work, and most of it can be started now.
The goal, in plain words. Many users share one agent service. Each user has their own API key for
the model. We don't want the agent to ever hold a real key — the agent reads prompts and tool output,
so anything it holds can be talked out of it by a malicious prompt. So: give the agent a fake key,
and have a trusted proxy on the way out swap the fake key for the real key belonging to that user.
Cortex is that proxy. One sentence: Cortex should be able to tell which user a request belongs to,
and inject that user's credential.
What already shipped on the MOCA side. Merged: a per-user credential store, and a per-turn
exchange that hands the agent a fake key naming the user (
sh-placeholder-<user>). This issue used tobe blocked waiting on that. It isn't anymore.
What's missing in Cortex.
static-injectchooses a credential by destination host, or by onefixed key. It has no concept of who is calling. So with many users you get one of two bad outcomes:
everyone shares a single credential (no isolation), or everyone but one person gets a 401.
One trap to know about. The obvious fix is to read the user's name out of the fake key in the
request. Don't — the fake key is predictable and it arrives from code the model can influence, so any
sandbox could present someone else's fake key and get their real credential. Identity has to come from
something the caller can't choose, which is why the real fix is connection-based.
What to build, in order. Steps 1–4 need nothing from MOCA:
key_by: identitymode tostatic-injectthat usespctx.Identity.Subject()as the resolver key. The pieces are already there —pipeline.Contextcarries an
Identityinterface (core/pipeline/context.go:26,:152) that no plugin currentlyreads, and
FileResolveralready maps one key to one credential file. This is the core of theissue and it's mostly wiring.
and self-contained.
it to every request on that connection, including requests bridged inside a CONNECT tunnel.
Cortex has
tls_bridgealready, but identity doesn't survive into the inner requests.only step that's actually waiting on MOCA.
Step 1 is the natural first PR — it closes the headline gap on its own.
Tracking: epic rossoctl/rossoctl#2546 (Stream 1) lists "
moca#241/cortex#905— Z5 injectordependency" as open; moca#241 is the MOCA-side stub pointing here; MOCA's spec index names this as a
prerequisite for MU3, which retires a documented stopgap where the real key passes through the agent's
memory on every turn.
I'll retitle this issue and fix the stale file paths (the code moved from
authbridge/authlib/tocore/plugins/) so it reads like the above. Happy to walk through step 1 together./cc @huang195
[-]Z5: per-subject credential resolution in static-inject (RFC 8693)[/-][+]Z5: connection-bound caller identity + identity-keyed credential resolution in static-inject[/+]pdettori commentedon Oct 21, 2026
Gap analysis (2026-10-21): Cortex as the egress proxy for MOCA's sandbox service
The question we're answering: what does Cortex need before it can be the egress proxy for MOCA's sandbox service (SBX0, Firecracker microVMs on a shared host)? At minimum it has to inject each user's keys in place of a placeholder, and let MOCA run other Cortex plugins as extensions.
Read against Cortex
mainat15da639and MOCAmainat95ff373. This is a reading of the code; we have not built or run Cortex. The target is the contract in MOCA MI1 §8 and the conformance suite in §12.3. This updates the dated §2.4 survey (taken at403d5d2) to today's HEAD.The ordered breakdown above (steps 1–5) still holds. Items G5, G7 and G8 below are not in it and should be added.
Gaps that block per-user key injection
15da639Proxy-Authorizationis deleted without being checked (forwardproxy/server.go:1133). Session ids come from client headers (core/session/idheader.go).pctx.Identityis only set by inboundjwt-validation, so it is nil on the forward pathvmpool(SCM_RIGHTSon a control socket; the descriptor is the identity, MI1 §8.3)net.Listen("tcp", …)(bootstrap.go:88,cmd/cortex/listeners.go:75)bridgedHandler(server.go:1033) passes only process info.serveOutboundbuilds a freshpipeline.Contextper request (:321)static-injectsupports onlykey_by: host | static, with onesecret_dirper process (staticinject/plugin.go:22-25).token-exchangeexchanges the inbound bearer, so a bearer would have to live inside the guestbindingdeclares:Bearer,Basicfor git over HTTPS,x-api-keystatic-injectreturns 401 when there is noBearer(plugin.go:188). Git's credential helper sendsBasic, so git fails.abph_handles are not a substitute: the placeholder-swap design has "no handle-level audience binding in v1"403 plaintext_credential, with nothing injectedstatic-injectdoes not checkpctx.Scheme. An absolute-formhttp://request (server.go:308) would have the credential injected in cleartext502 upstream_unverifiedwhen verification fails, never a silent tunneltlsbridge/decision.go:239).DefaultPassthroughHostsstarts with GitHub (:85), the main host that needs a credential.passthrough_hosts: []overrides the list; nothing turns off the fallbackEgress policy MOCA needs whether or not a credential is involved
403 destination_denied. Not found:skip_hostsis a bypass list. Anoparule on the CONNECT pipeline might cover it; we have not checked.169.254.169.254), private, unique-local and the host's own addresses, then dial the address that was checked so a second DNS answer cannot redirect the connection. Not found.429. Not found.session-budgetkeys onpctx.Session.ID, which comes from client headers.Upgradeis stripped on intercepted requests (server.go:1138). MOCA's contract allows upgrades.Host≠ CONNECT authority →421(server.go:344), and the upstream certificate is verified before a leaf is minted.Control and multi-tenant hygiene
Register{vm_id, sid, grant, listen_fd}/Rebind/Unregister, with callers admitted bySO_PEERCREDand every live VM re-registered after a proxy restart. The session API is read-only and unauthenticated (sessionapi/server.go:199,docs/session-api.md), and hot reload refuses listener changes.kid:base64-DER, not JWKS. Small.Plugins as extensions
The plugin model fits. Plugins register in
init()behind build tags, so MOCA can link its own identity and resolver plugins into a downstream build without forking Cortex. Three things to keep in mind:opareadspctx.Identity;session-budget,inference-routerandibacreadpctx.Session, which comes from client headers. G1/G3 must fill both, and should override any session header the client sends.ibac,tool-pruneandcontext-gururead bodies. MOCA's contract streams bodies and never buffers them, so these become per-host opt-ins.ibacalso needs the user's intent, which lives on the harness side and would have to arrive over the control channel.Smaller alternative
If MOCA puts its own front end in front of Cortex, Cortex has less to do. That front end would own the vsock sockets, the connection → sandbox binding, the allowlist, the SSRF check and the control channel, and stamp the verified identity onto the guest's plaintext CONNECT. Cortex would then need: trust that identity header only on the front end's socket (G1, scoped down); G3; G4; G5; G6; G7; and dial the address the front end pinned rather than resolve the name again. That is P4.1 §12.2's "Go shim" option.
MOCA's current position is unchanged (MI1 D4):
moca-egressfirst, then Cortex via the §12.3 suite once a Cortex-only plugin is needed. Neithermoca-egressnor the suite exists yet. MOCA-side status is on moca#241.Assisted-By: Claude (Anthropic AI) [email protected]
pdettori commentedon Oct 22, 2026
Superseded by #1490: Cortex as the egress proxy for MOCA's sandbox service (SBX). Cortex maintainers asked for one epic with an issue per gap, so the design sessions can take them one at a time.
Everything actionable here has moved into a child issue. Each one has the current code evidence (Cortex
maind4394da), what MOCA's contract needs, design questions, and the MOCA conformance case that proves it is done:The epic replaces #905 under rossoctl/rossoctl#2546. The MOCA-side stub is still rossoctl/moca#241. Closing.