Repository navigation
Not planned
Not planned
Copy link
Labels
enhancementNew feature or request
Description
Priority: P0 · Part of the Cortex × MOCA SBX epic · #905 breakdown step 4 · MOCA contract: MI1 §8.3, §8.5 item 1
Problem
One egress Cortex serves many users' sandboxes at once, so it has to tell them apart. Their requests are generated by code a model can influence, so anything inside a request can be forged: a session header, a bearer token, the placeholder (sh-placeholder-<subject> is predictable). Identity has to come from how the connection arrived, and it must not change for any request carried on that connection.
What Cortex does today
- The forward listener is unauthenticated.
Proxy-Authorizationis deleted without being checked (forwardproxy/server.go:1133). - Session ids come from client headers (
X-Claude-Code-Session-Id,X-Task-Id,X-Session-Id,core/session/idheader.go:20-59). pctx.Identity(core/pipeline/context.go:192) is set only by inboundjwt-validation(jwtvalidation/plugin.go:439), so it is nil on the forward path.- Identity set at CONNECT does not reach the inner requests:
bridgedHandler(server.go:1033) passes only process info;serveOutboundbuilds a freshpipeline.Contextper request (:321).
- Plugins read identity from two different fields:
opareadspctx.Identity;session-budget(sessionbudget/plugin.go:782),inference-routerandibac(ibac/plugin.go:464) readpctx.Session, which comes from headers.
What MOCA needs
- An accepting connection maps to a VM, the VM to a session (
sid), and the session to its current grant. The proxy never asks the guest who it is. - No binding, or an expired grant, gets
403 grant_expired. - The identity applies to the CONNECT and to every request bridged inside it.
- It fills both
pctx.Identityandpctx.Session, and overrides any session header the client sent.
Design questions
- Where does the binding live? Per listener (shape A: one listener per VM, see issue 2), or a trusted header on one front-end socket (shape B)?
- Do we want a connection-scoped context type that
bridgedHandlerandserveOutboundboth derive from, rather than copying fields? - Precedence: should a connection identity replace header-derived session ids, or should header-derived ids be disabled on this listener type entirely?
- Recording: does the subagent and client attribution added in
ResolveClient(context.go, since15da639) stay header-based and informational only?
Done when
- MOCA conformance cases
identity_from_connectionandforged_session_header_ignoredpass. - A unit test shows that two connections with different bindings, sending identical headers, get different
pctx.Identity.Subject()andpctx.Session.IDon bridged inner requests.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsDone
Activity
Feat: Deny-by-default egress allow list for the forward proxy (#1548)
Feat: Per-VM socket handover and control channel for MOCA SBX (#1569)
huang195 commentedon Nov 23, 2026
Replaced by #2087 (the caller context from the connection) and #2090 (the subject from moca's grant), under #2042. Please do not build this issue's own spec.