Repository navigation
docs(sbx): user-scoped egress credentials for sbx microVMs — spec + ADR-0046 - #624
Conversation
Phase 1 resolves a sandbox owner's sandbox-egress credential at moca-egress by owner lookup with a per-KVM-host bearer; phase 2 (owed) by the user's sandbox token on Exec.grant. File store on a PVC, Vault as a follow-up. Amends SBX0 §4.1/§11, MI1 (SBX path, stale ADR-0037 pointer) and P4.1. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Thanks for this. The phase split, the fail-closed lookup, the one-code 404 sandbox_not_found and the write-time narrowing of bindings all look right to me. I reviewed the design against one question: does it cover more than GitHub, in particular credentials for MCP servers reached over Streamable HTTP as an extension? I also compared it with how NVIDIA OpenShell manages credentials (main @ e5adf6f).
What already generalizes. The sandbox-egress consumer, the kind registry (credential-store.ts says "adding SigV4 or an MCP server's token is a registry addition"), --host and §6.3 already cover an MCP server on its own host with one static bearer. MCP over Streamable HTTP is plain HTTP/1.1 POST plus SSE, so the interception path in §5.2 carries it unchanged.
Where it stops generalizing. These three points are cheap to settle now. They get expensive once the §4.2 wire shape and the conformance cases are frozen, because the conformance suite is also the Cortex contract (MI1 S6).
- Matching is by host only (inline 1). An MCP gateway that serves several servers on one host, or a credential that needs a port, either can't be expressed or returns
409on every request. - One header per credential, both on the wire and in the Go
Credential(inline 2). Some APIs and MCP servers need two headers. - No resolver seam for short-lived tokens (inline 3). MCP authorization is OAuth 2.1, and most remote MCP servers hand out access tokens that last about an hour. The static
oauth2-tokenkind goes stale between stores.
How OpenShell does it (cited from NVIDIA/OpenShell docs and code):
| OpenShell | This spec | |
|---|---|---|
| Type vs instance | Provider profile (YAML data: credentials[], endpoints[] with host/port/path, binaries[], refresh, token_grant), imported with openshell provider profile import. Separately, provider instance holds the values. No compiled registry. |
Kind registry in code (fields + one default binding). Presets are CLI code (--preset github). |
| Binding | Each credential resolves only at the host, port and path glob of its profile's endpoints. Anything else gets 403 credential_endpoint_mismatch plus an OCSF event. |
Exact host. |
| Placement | header / Basic / bearer / query / path, SigV4 re-signing, opt-in body and WebSocket rewrite | One overwritten header |
| Guest side | Handle placeholders openshell:resolve:env:<handle>. The proxy replaces only the placeholder it sees, so the guest can pick between two credentials without holding either. |
One inert moca-placeholder. The proxy overwrites the header, and the credential is chosen by host. |
| Short-lived tokens | The gateway does the refresh (oauth2_refresh_token, client_credentials, STS, …). Refresh material is never injected. token_grant does RFC 8693 exchange or a JWT-SVID assertion on demand. |
Out of scope (§11) |
| Store | Pluggable CredentialDriver gRPC (db / k8s-secrets / vault, in-tree or out-of-process) |
CredentialStore (file / vault / k8s). Already equivalent, no change needed. |
| MCP | protocol: mcp endpoints with L7 method and tool-name rules. MCP traffic gets the same credential rewrite. I found no MCP-specific OAuth 2.1 discovery. |
Nothing MCP-specific, which is fine for phase 1 (E8) |
Proposed approach. Keep phase 1's scope. Change three contracts so that MCP, and anything else that is not GitHub, becomes a data addition rather than a redesign:
- Destinations become
{host, port?, pathPrefix?}. The lookup answers per(sandbox, host)with that owner's set of bindings for the host.moca-egresspicks the most specific prefix per request after interception, so it is still one round trip per(sid, host)per TTL. Overlapping destinations are refused atPUTtime, so409never shows up at use time. - The wire returns
headers: [{name, value}]and an optionalexpiresAt. The GoCredentialcarries a slice.bindingsbecomes a list on the descriptor, with an optional per-destination override, and §4.4's A0 fallback becomes the normal case instead of a contingency. - §4.2 step 4 is named as the resolver seam:
static(phase 1) |oauth2-refresh|token-exchange(Z5 §4.1's Mint resolver). Refresh material never leaves the control plane, andttlSeconds = min(configured, token remaining). You only need to record it, not build it. Then the ADR can say the lookup contract does not change when a resolver is added. - Presets become data: a small catalog in the repo of
{id, kind, destinations, bindings, resolver, hint}that--presetreads.github, GitHub's remote MCP server (api.githubcopilot.com), and an internal MCP gateway are then entries, not code. - Optional, later: named placeholders (
moca-cred:<name>), OpenShell-style, so a guest can selectgithub-workvsgithub-personalon one host. Destination binding still bounds where each one can go.
The inline comments are on the spec and the ADR. CI is green (14/14), the PR is a draft, and it's docs only. No .claude/ or .vscode/ changes.
| applies at `handlers.ts:495`). A removed user's sandbox gets `404 no_credential`, so injection | ||
| stops within one TTL of the removal rather than at the sandbox's expiry. _(Builder's call.)_ | ||
| 3. **Credential.** List the owner's descriptors and keep those with `consumer: sandbox-egress` and an | ||
| exact, case-insensitive `destination.hosts` match for `host`, with no wildcards in phase 1. None |
There was a problem hiding this comment.
suggestion (extensibility): the match is on host only, so two credentials with the same host can never both be used. That's fine for GitHub, but MCP setups commonly put several servers behind one host: an internal MCP gateway at mcp.corp.example/github, /jira, /docs, each with its own token. Today that is either inexpressible or a 409 on every request. Some internal services also need a port (host:8443).
Suggest destination: [{host, port?, pathPrefix?}] (exact host, port defaulting to 443, a prefix on a / boundary). The lookup still answers per (sandbox, host), but returns that owner's set of bindings for the host. moca-egress picks the longest matching prefix per request after http.ReadRequest, so it is still one round trip per (sid, host) per TTL. Overlaps are refused at PUT time, so ambiguity is a write-time error and 409 no longer happens at use time. A host with no path match is still intercepted, but gets nothing injected.
This is credential selection, not the path policy E8 rejects. OpenShell draws the same line: a static credential resolves only at the host, port and path glob of its profile's endpoints, and anything else gets 403 credential_endpoint_mismatch (docs/how-it-works/providers/profiles.mdx:47-74).
If this is out of scope for phase 1, please record destination as the extensible shape now (a host string is {host}), so the §4.2 wire and the conformance cases don't freeze host-only.
There was a problem hiding this comment.
Adopted in ec21394, with one change to the shape: spec E10, §4.2 "Destination entries", and §5.2 "Selection".
- Destinations are
host[:port][/prefix]. Port defaults to 443 and the prefix to/, on a/boundary. They are stored as strings in the existingdestination.hostsrather than a new structureddestination: [{…}]. A bare host is today's entry, so none of the three stores, the harness profile ormocactl's types change shape. The wire tomoca-egresscarries the structured triple (port,pathPrefix). - The lookup returns the owner's set for the host.
moca-egresspicks per request: same port, then the longest prefix. It is still one round trip per(sid, host)per TTL. - Identical destinations are refused at
PUTwith409 destination_conflict, naming the other credential. Nested prefixes are not a conflict, because the longest wins.credential_ambiguoussurvives only as a write-race guard. - An unmatched path is still intercepted and forwarded with nothing injected, as you proposed.
- One addition you didn't mention: when any element for a host is path-scoped, a request path with a dot-segment, a
\or an encoded.///\is refused400before anything is injected. Otherwise a gateway that normalizes paths would route/github/../jirawith the GitHub token. It is conformance case 11.
E8 now states the policy/selection line explicitly.
| // Lookup reports the credential for c's session at host: found, none, or an error. | ||
| Lookup(ctx context.Context, c Caller, host string) (Credential, LookupResult, error) | ||
| } | ||
| type Credential struct{ Name, Header, Value, Subject string } |
There was a problem hiding this comment.
suggestion (extensibility): Credential{Name, Header, Value, Subject}, and §4.2's {header, value}, allow one header per credential. Some APIs and MCP servers need two, for example a key plus a tenant or org header, or Atlassian-style Authorization plus an account header. The A0 fallback in §4.4 already says "a different binding per destination".
Suggest Headers []Header on the wire and in Go (headers: [{name, value}]), plus an optional expiresAt, and bindings: [] on the descriptor. A list of one is today's case. The write-time narrowing in §4.2 step 4 (no hop-by-hop, Host, Proxy-*, X-Moca-*, CR/LF) applies to each entry. This costs nothing in phase 1, but changing it after moca-egress and the conformance suite ship is a wire break.
There was a problem hiding this comment.
Adopted in ec21394: spec §4.2 steps 3–4, and §5.1 for the Go types.
- Wire: each element carries
headers: [{name, value}]andexpiresAt. The Go side isCredential{…, Headers []Header, ExpiresAt time.Time}. - Descriptor:
bindingmay be one binding (stored unchanged, so existing documents compare equal) or a list of 1–4. Header names must be unique case-insensitively, and the write-time narrowing applies to every entry.Cookieis added to the refused headers. - On the A0 fallback, I went a slightly different way from per-destination overrides on one credential. The
githubpreset writes two credentials from the one PAT if A0 fails. That keeps the descriptor at "one binding or one list" with no per-host map. The trade-off is recorded in §12.
| exact, case-insensitive `destination.hosts` match for `host`, with no wildcards in phase 1. None | ||
| returns `404 no_credential`. More than one returns `409 credential_ambiguous`, never resolved by | ||
| order (MI1 §6.3 item 4). | ||
| 4. **Render.** `get(owner, name)` decrypts. The binding's `format` is rendered server-side: the |
There was a problem hiding this comment.
suggestion (extensibility): please name this step as the resolver seam and say the §4.2 contract is resolver-neutral: resolver: static (phase 1, decrypt + render) | oauth2-refresh | token-exchange (Z5 §4.1's Mint resolver, RFC 8693). This matters most for MCP. MCP authorization is OAuth 2.1, and the remote MCP servers I know of (GitHub's at api.githubcopilot.com/mcp/, Atlassian, Linear and the like) hand out roughly one-hour access tokens with a refresh token. Stored as the static oauth2-token kind, the credential goes stale between PUTs.
With a resolver, the control plane holds the refresh material, which is never returned on the wire. It refreshes on lookup, persists any rotated refresh token, and caps ttlSeconds at the access token's remaining life. moca-egress doesn't change. OpenShell does exactly this: gateway-managed refresh.strategy (oauth2_refresh_token, oauth2_client_credentials, STS) with refresh material stored separately and never injected, plus an on-demand token_grant (profiles.mdx:561-659, 808-857).
§11 can keep OAuth flows out of scope. The ask is only that the seam and the TTL cap are in the design, so adding a resolver later is not an ADR change.
There was a problem hiding this comment.
Adopted in ec21394. Spec E11 and §4.2 step 4 now name the resolver seam:
staticis the only resolver in phase 1: decrypt and render,expiresAt: null.oauth2-refreshkeeps the refresh material in the store, refreshes on lookup, persists a rotated refresh token, and returns the access token's expiry. Refresh material never goes on the wire.token-exchangeis Z5 E6 / §4.1's mint.
ttlSeconds = max(5, min(configured, seconds to the earliest expiresAt)). The plan pins it with a stub resolver test, so the seam is exercised in phase 1 even though only static exists. ADR-0046 says adding a resolver changes neither the lookup wire nor moca-egress. OAuth flows stay out of scope (§11), and the oauth2-refresh resolver is listed as an owed follow-up in the ADR.
| `rt.harness` (`headless.ts:249`). Their bodies are factored to take a `cp`-only readiness check (the | ||
| login and API-token validity half of `ready()`), and the `mocactl credentials` commands keep calling | ||
| them through `ready()`. `--consumer` is not offered: the client always sends `sandbox-egress`. | ||
| - `--preset github` sets kind `basic`, hosts `github.com` and `api.github.com`, and `username = |
There was a problem hiding this comment.
suggestion (extensibility): consider making presets data rather than CLI code: a small catalog in the repo of {id, kind, destinations, bindings, resolver, hint} that --preset reads and that mocactl sbx credentials presets lists. github is the first entry. GitHub's remote MCP server (api.githubcopilot.com, Bearer PAT), Jira and an internal MCP gateway are then reviewed data additions, not new branches in sbx/cli.ts. OpenShell takes this to its conclusion: provider types are imported YAML profiles with no compiled registry (providers/github.yaml, openshell provider profile import). The kind registry in credential-store.ts stays the place for field and validation rules.
There was a problem hiding this comment.
Adopted in ec21394: spec E12 and §7.
- The catalog is a data-only module,
packages/mocactl/src/sbx/presets.ts. It's a.tsfile rather than YAML/JSON because mocactl's tsconfig and esbuild bundle take no JSON imports today, and adding a loader for one file isn't worth it. The module exports one frozen array and nothing else, and a schema test enforces that. - Each entry is
{id, description, hint, credentials: [{suffix, kind, destinations, binding?, fixed, stdinField}]}.--preset IDreads it, andmocactl sbx credentials presetslists it. - The first entries are
githubandgithub-mcp(api.githubcopilot.com, Bearer PAT, which ships only if A0's MCPinitializecheck passes). Jira or an internal MCP gateway is then a reviewed array entry. - The kind registry in
credential-store.tsstays the place for field and validation rules, as you suggest.
|
|
||
| ### 6.3 Internal services | ||
|
|
||
| Nothing in the design is specific to GitHub. For an internal REST service, the operator does three |
There was a problem hiding this comment.
suggestion: please name MCP here explicitly, since it is the main non-GitHub case: an MCP server over Streamable HTTP is an "internal REST service" for this design. A few MCP-specific notes that could go in this section:
- The binding sets the header, so an MCP client in the guest that sends no
Authorizationat all still gets it. No placeholder config is needed in.mcp.json. Worth saying, because MCP clients usually start OAuth discovery on a401instead of sending a token. - Streamable HTTP's
GETSSE stream is one long-lived response. §5.2's re-read on each request therefore revokes it only when the client sends its next request, not within one TTL. Either close intercepted long-lived responses when the cached lookup turnsnone, or relax acceptance item 6 for streaming responses. - Hosted MCP servers increasingly negotiate HTTP/2. ALPN
http/1.1(§5.2) is fine as long as the server still accepts it, so it's worth a line in §11.
There was a problem hiding this comment.
Adopted in ec21394: §6.3 is now "Internal services and MCP servers", with each of your points.
- Set, not replace. The headers are set even when the client sends none, so
.mcp.jsonneeds no placeholder and the client never gets the401that would start OAuth discovery. Conformance and unit tests cover it. - Long-lived SSE
GET. I chose your second option: acceptance item 6 is now "no request sent after the TTL carries it", and an in-flight response is not cut (§5.2). Revocation stops the credential being sent, which a streaming response doesn't do. Its next request on that connection is refused401 credential_revoked. A timer-driven stream closer would add a goroutine per intercepted connection and a race with the response writer, and buy nothing the token-scoping guidance doesn't already cover. The plan hasTestInterceptStreamingResponseNotCut. - HTTP/2. Noted in §6.3 and §11: interception offers
http/1.1only, and an upstream that stops accepting HTTP/1.1 is the trigger to add HTTP/2 interception. A0 now also checksapi.githubcopilot.comwith--http1.1.
Named placeholders (moca-cred:<name>) are recorded in §11 as a later addition with no wire change.
| to the host token. Phase 2 does not change what users see, and it is the SBX path's version of MI1's | ||
| sandbox grant. | ||
|
|
||
| The proxy enforces no repository- or path-level policy. Users scope their tokens, for example with a |
There was a problem hiding this comment.
suggestion: the ADR records the GitHub mechanism well but not the property that makes it general. Since this ADR is what a later MCP or internal-API increment will cite, consider adding a sentence to Decision, for example: "The lookup is type-agnostic: a credential is selected by (owner, destination) where a destination is host[:port][/path-prefix], it renders to one or more headers, and how its value is produced (static, refreshed, exchanged) is a control-plane resolver behind the same contract. GitHub is the first preset; MCP servers and internal APIs are data additions." Also, this line rejects path policy. Path-scoped credential selection is a different thing, and the ADR shouldn't be read as ruling it out.
There was a problem hiding this comment.
Added to the Decision in ec21394. It is close to your wording: the lookup does not depend on the credential's type, selection is by (owner, destination) with host[:port][/path-prefix], a credential renders to one or more headers, values are produced by a control-plane resolver behind the same contract, and presets are data, so MCP servers and internal APIs are data additions. It also now says that rejecting path policy does not rule out path-scoped credential selection, and it lists the oauth2-refresh resolver as owed follow-up.
… seam, presets as data, MCP - E10: destinations are host[:port][/prefix], stored as strings in the existing destination.hosts; the lookup returns the owner's set for a host and moca-egress selects per request by port and longest prefix; identical destinations are a write-time 409 destination_conflict; dot-segment/encoded paths are refused when a host is path-scoped. - Bindings may be a list of 1-4 headers; the wire returns headers[] and expiresAt. - E11: §4.2 step 4 is the resolver seam (static now; oauth2-refresh and token-exchange later behind the same contract); ttl capped by expiresAt. - E12: presets are a reviewed data catalog (github, github-mcp). - §6.3 names MCP over Streamable HTTP; in-flight streams are not cut on revoke. - ADR-0046 records the type-agnostic property and the policy/selection line. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
All six suggestions are addressed in ec21394 (spec v1.1 and ADR-0046), with replies on each thread. In short:
Named placeholders are recorded in §11 as a later addition. The OpenShell comparison is in §12, and the provider-profile-YAML route is noted as not needed while presets are reviewed in this repo. |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up on ec21394 (round 1 was on 57f7cdb). All six round-1 suggestions are adopted, and I checked each one against the spec and ADR text, not only the replies. E10–E12, the headers[]/expiresAt wire, the resolver seam, §6.3 for MCP, the §12 alternatives and the ADR's policy-versus-selection line are all present and consistent. The traversal refusal you added on top is a good catch.
The inline comments cover new detail that the round-2 changes introduce:
- Revocation vs. no-match (§5.2) is now ambiguous once selection is per path, and a deleted
/acan silently fall back to/'s token. This is the one I'd settle before the plan. - Path-confusion refusal:
..;matrix params and double encoding get past it. - Two reply/spec mismatches:
Cookieisn't in the refused-header list, and--http1.1is missing from A0. - §10.1 doesn't list tests for the new wire shape. Two small status-code and TTL nits, and one ADR wording nit.
No must-fix. CI is green (14/14), the PR is docs only, all commits are signed off, and there are no .claude/ or .vscode/ changes.
| bodies are streamed. Keep-alive is supported. **Each request re-reads the credential through the | ||
| cache** (no network call while the entry is fresh). When the set no longer contains the element | ||
| this request selects (the credential was deleted, the owner was removed, or the sandbox ended), | ||
| the request is answered `401 credential_revoked` and the connection is closed. A long-lived `git` |
There was a problem hiding this comment.
suggestion: revocation and "no match" now overlap. §5.2 says a request that matches no element is "forwarded without injection" (and conformance case 10 tests that). This bullet says that when the set "no longer contains the element this request selects", the answer is 401 credential_revoked. Selection runs against the fresh set, so once a credential is deleted the request selects nothing, or it falls back to a shorter prefix. Neither rule says which outcome applies. Two concrete cases:
/ais deleted and/remains. The next/a/xon the same connection silently gets/'s headers, which may be a different token for a different server behind the gateway. It does not get a 401./ais the only credential and it is deleted. The next/a/xcould be a 401 (case 9) or a no-injection forward (case 10).
Please define it with per-connection state, for example: "a connection remembers the credential names it has injected. A later request whose fresh selection differs from what the same prefix selected before (removed, or replaced by a shorter one) is refused 401 credential_revoked and the connection is closed." Alternatively, scope the 401 to "the fresh set is empty". Either way, cases 9 and 10 should pin the boundary.
There was a problem hiding this comment.
Fixed in 52cf778 with the per-connection rule (§5.2, "Revocation is decided per connection"). A connection remembers every (pathPrefix, name) it has injected. On each request, every remembered pair whose prefix covers the path must still be in the fresh set. If one is missing, the answer is 401 credential_revoked and the connection closes, whatever the fresh selection would now pick. So a deleted /a never falls back to /'s token on a connection that used /a. A path that no remembered prefix covers is selected afresh, and no match there still means forwarded without injection. The boundary is pinned by case 9(a) (/a gone, nothing left), case 9(b) (/a gone, / remains, still 401), and case 10 (no match on a fresh connection, and on a connection that injected /a but for an uncovered path).
| `{field}` substitution and `{base64(a:b)}`. `PUT` today accepts any `{header, format}` for a | ||
| non-inference consumer (`credential-store.ts:270-274`), so for `sandbox-egress` it is narrowed at | ||
| **write time** to formats built only from those two forms over the kind's declared fields, and to | ||
| a header that is not hop-by-hop, `Host`, `Proxy-*` or `X-Moca-*`. A stored credential therefore |
There was a problem hiding this comment.
nit: the #624 thread reply says "Cookie is added to the refused headers", but the write-time rule here still lists only hop-by-hop, Host, Proxy-* and X-Moca-*, and Cookie appears nowhere in the spec. Please add it here (and probably Set-Cookie, since a request has no use for it), so the plan and §10.1 pick it up.
There was a problem hiding this comment.
Fixed in 52cf778: Cookie and Set-Cookie are now in §4.2 step 4's refused list and in §10.1. The reply had got ahead of the spec text.
| - **Selection (E10).** Among the elements with the CONNECT port, take the one with the longest | ||
| `pathPrefix` that matches the request path on a `/` boundary (`/github` matches `/github` and | ||
| `/github/x`, not `/githubx`). When **any** element for this host has a prefix other than `/`, a | ||
| request path with a dot-segment, a backslash, or a percent-encoded `.`, `/` or `\` (any case) is |
There was a problem hiding this comment.
suggestion: the path-confusion refusal covers dot-segments, \ and encoded .///\. Two common gateway normalizations still get past it:
- Matrix/path parameters. Tomcat, Jetty and Spring strip
;…from a segment, so/github/..;/jira(segment..;) and/github;x/../jiraroute to/jira. Neither is a literal dot-segment. - Double encoding.
%252e%252esurvives one decode as%2e%2e, and a gateway that decodes twice routes it.
Since the prefix syntax already bans % (§4.2), the simplest rule is: when any element for the host is path-scoped, refuse a request path that contains ;, any %-escape at all, \, or a dot-segment. Legit git/gh/MCP clients don't send these. Conformance case 11 could add ..; and %252e.
There was a problem hiding this comment.
Adopted your simplest rule in 52cf778 (§5.2, "Path confusion"). When any element for the host is path-scoped, the request is refused 400 with nothing sent upstream if its raw path contains a dot-segment, \, ;, or any %-escape. That covers ..;, ;x/../, %2e and %252e alike, and it matches the prefix syntax already banning %. A host whose only prefix is / (GitHub) is unaffected. Case 11 now includes /a/%252e%252e/b, /a/..;/b and /a;x/../b.
| "expiresAt": null } ] } | ||
| 404 { "error": "no_credential" } -- sandbox live and on H, owner has none for host | ||
| 404 { "error": "sandbox_not_found" } -- unknown, terminated, or not on H (one code: no oracle) | ||
| 400 { "error": "credential_ambiguous" } -- two identical destinations (a write race only, see E10) |
There was a problem hiding this comment.
nit: credential_ambiguous moved from 409 to 400, but the request is well-formed. The fault is server-side state from a write race. A 4xx telling moca-egress it is "the caller's fault" is misleading, and if a future client retries 409s and not 400s, it diverges. I'd keep 409 or use 500 credential_ambiguous. moca-egress maps either to 503 credential_unavailable (§5.1), so nothing else changes.
There was a problem hiding this comment.
Agreed, and changed in 52cf778 to a new code, 500 destination_ambiguous, rather than reusing credential_ambiguous. That existing code is the 400 for inference session creation (errors.ts:86), where the request really is ambiguous, so I left it alone. moca-egress maps the new code to 503 credential_unavailable, as you note.
| - Route membership: the four routes on `sandbox` only when enabled. `route-profile.test.ts` and | ||
| the authz enumeration cover both shapes. | ||
| - `PUT` on `sandbox` refuses the `inference` and `control-plane` consumers. | ||
| - §4.2's matrix: wrong or absent bearer; a token valid for host A asking about a sandbox on host B |
There was a problem hiding this comment.
suggestion: §10.1 wasn't updated for the v1.1 contract. The matrix doesn't name: destination parsing and normalization (host:443 → host, the forbidden prefix characters, the non-sandbox-egress bare-host rule); 409 destination_conflict vs. nested prefixes allowed; one host yielding several elements (two ports or prefixes); a binding list (1–4 entries, case-insensitive duplicate refusal, narrowing per entry); and ttlSeconds capped by expiresAt with the 5 s floor (the stub-resolver test the reply mentions). These are the parts of the wire the conformance suite and Cortex will freeze, so please list them here rather than only in the plan.
There was a problem hiding this comment.
Fixed in 52cf778: §10.1 now lists destination parsing and normalization (including host:443 → host), the refused forms and the bare-host rule for other consumers, 409 destination_conflict versus nested prefixes, binding lists (1–4, case-insensitive duplicates, narrowing per entry including Cookie/Set-Cookie, ordered rendering), several elements per host with their sort order, 500 destination_ambiguous from a seeded race, and ttlSeconds (the stub resolver at now+20 → 20, the clamp floor 2 s → 5, null → configured).
| unauthenticated" answerable. | ||
|
|
||
| `ttlSeconds` is the smaller of `SH_EGRESS_CREDENTIAL_TTL_SECONDS` (default 60, range 5–300) and the | ||
| seconds left until the earliest non-null `expiresAt`, floored at 5. Rotating or deleting a credential |
There was a problem hiding this comment.
nit: a floor of 5 combined with the expiresAt cap means a token with 2 s left is cached for 5 s, so moca-egress sends it for up to 3 s after it has expired. This doesn't matter for static, but please add a sentence for later resolvers: a resolver must refresh (or not return) a value with less than the floor remaining, so the cap never yields an already-expired header.
There was a problem hiding this comment.
Added in 52cf778 (§4.2, after the ttlSeconds rule): a resolver must never return a value with less than the 5 s floor left. It refreshes it or omits the element, so the floor can't cause an already-expired header to be sent. It binds only later resolvers, because static never expires.
| GitHub's (`github-mcp` preset). The seam is in the contract, so adding the resolver changes | ||
| neither the wire nor `moca-egress`. | ||
| - **HTTP/2:** interception offers ALPN `http/1.1` only (§5.2). A hosted MCP server that negotiates | ||
| HTTP/2 still works as long as it accepts HTTP/1.1, which every Streamable HTTP server must for |
There was a problem hiding this comment.
nit: "which every Streamable HTTP server must for its SSE stream today" overstates it. The MCP Streamable HTTP transport doesn't require HTTP/1.1, and SSE works over HTTP/2. Suggest "as long as it still accepts HTTP/1.1, which A0 checks for api.githubcopilot.com with curl --http1.1". The reply says A0 does this, but §4.4 (line 269) doesn't mention --http1.1 yet.
There was a problem hiding this comment.
Fixed in 52cf778 with your wording: "as long as it still accepts HTTP/1.1, which A0 checks for api.githubcopilot.com with curl --http1.1". It also says the transport doesn't require HTTP/1.1 and that SSE works over HTTP/2. §4.4's A0 description now names --http1.1 too.
| **Phase 1 (this decision's first implementation):** `moca-egress` resolves the credential by sending | ||
| `(sandbox id, host)` to the control plane, authenticated with a **per-KVM-host** egress token. The | ||
| control plane answers only for live sandboxes running on that host's workers and returns the owner's | ||
| matching credential. The proxy caches it for at most 60 s. |
There was a problem hiding this comment.
nit: "caches it for at most 60 s": the spec makes the TTL configurable, 5–300 s with a default of 60 (§4.2, §4.3), and capped by expiresAt. Suggest "for at most the configured TTL (default 60 s)".
There was a problem hiding this comment.
Fixed in 52cf778: "caches them for at most the configured TTL (default 60 s; capped by any credential's expiry)".
…ath confusion, codes - §5.2: revocation is per connection (remembered prefix→name pairs), so a deleted /a never falls back to /'s token; no-match on a fresh path is forwarded uninjected. - Path-confusion refusal also covers ';' matrix params and any %-escape (single and double encoding) when a host is path-scoped. - Cookie and Set-Cookie join the refused binding headers. - Lookup write-race guard is 500 destination_ambiguous (stored-state fault). - Resolvers must not return a value with less than the 5 s floor left. - §10.1 lists the v1.1 wire tests; §4.4/§6.3 name curl --http1.1 for MCP. - ADR: TTL is the configured value (default 60 s), capped by expiry. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
What
Design for user-scoped egress credentials on
mocactl sbxmicroVMs (SBX0 increment 2b), plus its decision record.docs/specs/2026-10-26-sbx-egress-credentials-design.mddocs/adrs/0046-sbx-egress-credentials-owner-lookup.md(0046 because feat(control-plane): test-user logins behind a shared secret #620 holds 0045)The guest keeps the inert
moca-placeholdertoken.moca-egressTLS-intercepts only the hosts the sandbox owner has asandbox-egresscredential for, and overwrites the auth header. Every other allowlisted host stays an opaque tunnel, as in v0.8.0. Users manage credentials withmocactl sbx credentials(with--preset githubfor a fine-grained PAT), stored in the control plane'sFileCredentialStoreon a PVC. Vault is a follow-up and needs only configuration.Phases
moca-egresssends(sandbox id, host)to the sandbox control plane, authenticated with a per-KVM-host bearer. The control plane answers only for live sandboxes on that host's workers. Accepted risk, recorded in the ADR: a stolen host token yields the credentials of every owner with a live sandbox on that host.Exec.grant→ worker →moca-egress(Register/Rebind), and the control plane releases a credential only against it.Docs amended
/v1/credentials, but only when enabled.Prerequisite
#623:
deploy/sbx/install-host.shinstalls nomoca-egress.Docs only, no code. Draft until the implementation plan is written.
🤖 Generated with Claude Code