Repository navigation
feat(sbx): deploy, mocactl sbx credentials and docs for user-scoped egress credentials (SBX0.2b phase 1) - #646
Conversation
|
Live acceptance (plan Task 15): PASS on 2026-10-28 for a single user, on the SBX0 KVM host with the owner's OK. The full manifest, covering what was found, every change, cleanup and the rollback sequence, is in Setup
Smoke step 7 (
KVM gate
Not run: acceptance item 3 (a second user gets no credential). The operator skipped it, and it is marked pending in Left on deliberately: the feature stays enabled on the cluster and the host. The temporary allowlist addition for the MCP check has been removed, and the host token copy and staged files are deleted. |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
This is the last SBX0.2b chunk, and it looks solid: it's off by default with a golden test, and secrets stay out of argv. The drop-in credential names, MOCA_EGRESS_CREDENTIALS_URL, egress_key/egressTokenEnvName, the host-id regex and the template-worker rule all match remote-worker/internal/egress/config.go and packages/control-plane/src/egress-config.ts on main. The projected credentials volume correctly replaces the overlay's secret: source.
Author: pdettori (MEMBER, maintainer)
Areas reviewed: Shell, Kustomize/K8s, TypeScript (mocactl), Go (KVM gate test), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 12, all signed-off: yes
CI status: passing except trivy-scan. It's also red on unrelated #647, and this PR changes no dependency manifests, so it's likely a new advisory against an existing dependency. Please check it before merging.
Suggestions and nits are inline. None of them blocks merging. Acceptance item 3 (the second-user check) is still pending live, as documented.
|
|
||
| ### 2.1 Egress credentials (SBX0.2b, [spec](../specs/2026-10-26-sbx-egress-credentials-design.md)) | ||
|
|
||
| Rows for the user-scoped credential injection. The live rows are **open**: the live acceptance |
There was a problem hiding this comment.
suggestion: The intro still says the live acceptance "has not run, so none of them claims evidence yet", but f51db0c marks two rows "Tested live 2026-10-28" and adds the acceptance paragraph. Reword it to say that only the second-user row is still pending.
There was a problem hiding this comment.
Fixed in 5648bf2: the intro now says the live acceptance ran on 2026-10-28, two rows carry its evidence, and only the second-user row is pending.
| kek="$(json_value "$json" SH_CREDENTIAL_KEK)" | ||
| [[ -n "$kek" ]] || { log 'generating the credential KEK (SH_CREDENTIAL_KEK)'; kek="$(openssl rand -base64 32 | tr -d '\n')"; } | ||
| [[ "$(printf '%s' "$kek" | base64 --decode 2>/dev/null | wc -c | tr -d ' ')" == 32 ]] || | ||
| die 'sbx-egress SH_CREDENTIAL_KEK is not 32 bytes of base64: delete the key and re-run (this makes stored credentials unreadable)' |
There was a problem hiding this comment.
suggestion: The control plane's keksFromBase64 accepts a comma-separated KEK ring (newest first) for rotation. This check requires exactly 32 bytes, so the first setup.sh run after an operator adds a second KEK dies. Its message then says to delete the key, which makes every stored credential unreadable. Please accept the ring (validate each entry), or at least don't advise deletion when the value contains a comma.
There was a problem hiding this comment.
Fixed in 5648bf2: the check splits on , like keksFromBase64 and requires every entry to decode to 32 bytes. An existing ring is never rewritten. A bad ring is refused with a fix-by-hand message and no deletion advice. A bad single key keeps the delete advice, now with the warning that it makes stored credentials unreadable. New setup.test.sh case: a two-entry ring survives a re-run unchanged, and a ring with one bad entry is refused without deletion advice.
| systemctl reset-failed moca-egress.service || true | ||
| systemctl restart moca-egress.service || die 'moca-egress failed to start with credentials; the reason is in: journalctl -u moca-egress. Fix it and re-run' | ||
| wait_egress_ready "$SBX_ENV_DIR/moca-egress.env" | ||
| log "moca-egress now injects credentials; build snapshots with: deploy/microvm/build-snapshot.sh --egress-ca $d/ca.crt --out $SBX_SRV/snapshots/<image>" |
There was a problem hiding this comment.
suggestion: --egress doesn't look at workers that are already installed. In the fresh-host order, a worker installed in step 3 from a snapshot without the CA passes, because there's no drop-in yet, so check_snapshot_ca is skipped. Step 4 then turns on interception silently, and users get guest TLS failures. Consider warning about each installed worker whose SH_SNAPSHOT_IMAGE manifest lacks a matching egress_ca_sha256, and pointing at the reinstall.
There was a problem hiding this comment.
Fixed in 5648bf2: after the drop-in, --egress warns for every installed worker whose SH_SNAPSHOT_IMAGE manifest lacks egress_ca_sha256 or carries a different one. It warns rather than refuses because the fresh-host order installs the worker first. The manifest read is factored into snapshot_ca_fingerprint, shared with check_snapshot_ca. New install-host.test.sh case.
| # turning it off later leaves sbx-egress and the PVC in place | ||
| # SBX_EGRESS_HOSTS optional, with SBX_EGRESS_CREDENTIALS=1: kvm-a=sbx_default,sbx_py312;kvm-b=w3 | ||
| # (host ids ^[a-z0-9][a-z0-9-]{0,30}$; every SBX_WORKERS entry owned by exactly | ||
| # one host). Unset: one host, kvm, owning every worker |
There was a problem hiding this comment.
suggestion: This header says "every SBX_WORKERS entry owned by exactly one host" and "Unset: one host, kvm, owning every worker", and spec §4.3 (the SH_EGRESS_HOSTS row) says the same. But the code and the control plane require template workers only, and they refuse a non-template worker. Please align the wording with 7c76de6's template-worker check.
There was a problem hiding this comment.
Fixed in 5648bf2: the setup.sh header, the validation comment and spec §4.3 now say every template worker (listed in SBX_TEMPLATES_FILE) is owned by exactly one host, and the default kvm owns every template worker.
| [[ "$RC" == 0 ]] || fail "a public git ls-remote in user B's sandbox: exit $RC: $(lastline "$LOGS/cred-b-public.err")" || return 1 | ||
| release b "$bid" || return 1 | ||
| else | ||
| echo "ok 7 - B's sandbox gets a 401 and a public clone works # SKIP no second user" |
There was a problem hiding this comment.
nit: Without a second user, this prints an extra ok 7 - … # SKIP line before run_step's own ok 7 - …. The TAP output then has two results for test 7, and SKIPS is incremented for a step that counts as passed. A # step 7: … comment line would avoid both.
There was a problem hiding this comment.
Fixed in 5648bf2: the no-second-user path prints # step 7: second-user check skipped (no second user) as a TAP comment and no longer bumps SKIPS. smoke.test.sh updated.
| ? arg === undefined || | ||
| (arg === 'presets' | ||
| ? extra.length === 0 | ||
| : ['add', 'delete'].includes(arg) && extra.length === 1) |
There was a problem hiding this comment.
nit: mocactl sbx credentials list is a natural spelling, but it falls through to "unknown credentials command 'list'". Consider accepting list as an alias for the bare command.
There was a problem hiding this comment.
Fixed in 5648bf2: mocactl sbx credentials list is an alias of the bare form, and the usage line shows [list]. New test in sbx-credentials.test.ts.
…7045 trivy-scan went red on this branch (and on rossoctl#646, which touches no dependencies either): golang.org/x/net v0.61.0 in remote-worker and v0.60.0 in gen/go are vulnerable to CVE-2026-78661 (quadratic complexity coalescing text nodes in html) and CVE-2026-97045 (ancestor namespace transitions when rendering raw text), both fixed in v0.62.0. Both advisories are currently severity UNKNOWN, so the workflow's severity: CRITICAL,HIGH input does not gate them: trivy-action drops the severity filter when building the SARIF report ("with all severities"), and exit-code 1 then fires on any finding — verified by running the exact action invocation locally against this tree before and after the bump (exit 1 -> 0). gen/go additionally picks up x/sys v0.49.0 and x/text v0.43.0, the versions x/net v0.62.0 requires. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…on CA (SBX0.2b) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… only Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…d host CA Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ENTIALS=1 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…-mcp) mocactl sbx credentials [add NAME (--host DEST | --preset ID) | presets | delete NAME] on the sandbox login. The secret comes from stdin only. ready() splits into readyCp (login) and ready (readyCp plus harness) so the credential commands run without a harness; the MOCA `mocactl credentials` behaviour is unchanged. sbx up's steering gains the GH_TOKEN placeholder line. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…onflict Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…heck (final review) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Smoke step 7 (opt-in: SBX_SMOKE_GITHUB_TOKEN_FILE + SBX_SMOKE_GITHUB_REPO): store the PAT on stdin, clone/commit/push, owner check, placeholder 401, revocation, optional github-mcp and a second-user check. Runnable alone with only HOME_A. TestGateCredentialNeverInGuest scans the guest's files, environ and memory for the fixture credential. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…th over sun_path) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ty review Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…template-worker wording, smoke TAP, credentials list Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
f51db0c to
59b5623
Compare
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up at 59b5623: I verified all six items from the f51db0c review in the fix commit (59b5623, pre-rebase 5648bf2). The security-review intro is reworded. setup.sh accepts a KEK ring the way keksFromBase64 does and never advises deleting a ring. install-host.sh --egress warns for installed workers whose snapshot lacks or mismatches the CA fingerprint. The template-worker wording is aligned in setup.sh and spec §4.3. The smoke step-7 skip is a TAP comment. credentials list is an alias. Each fix has a test. The 12 earlier commits are unchanged by the rebase onto 2515473 (range-diff =). CI is all green. Acceptance item 3 (second user) is still pending live, as documented.
SBX0.2b egress credentials: rulings made during execution#624 (spec), #627, #630, #641 and #646 are all merged. These are the judgement calls I made without stopping to ask. Each line ends with the cost if the call was wrong. Process
Control plane
Egress proxy
Deployment
Deferred, not yet filed Each task's minor findings are in the ledger. The ones worth a follow-up issue:
Open
Assisted-By: Claude Code |
Sixteen ADRs still said Proposed although their decisions are in code on main. Each status line now names the merged PRs that implemented it and the date the core landed (format of ADR-0042), and notes what is still owed where only part is built: - 0028 (rossoctl#170, rossoctl#201, rossoctl#340; its KEDA transport removed by ADR-0041) - 0029 (rossoctl#171), 0030 (rossoctl#214), 0031 (rossoctl#214, rossoctl#225) - 0032 (rossoctl#249, rossoctl#350, as amended by MI1) - 0035 (rossoctl#251; ADR-0048 adds lease mode beside it) - 0036 (rossoctl#347), 0038 (rossoctl#458), 0039 (rossoctl#467), 0040 (rossoctl#481) - 0043 (rossoctl#560, rossoctl#588, rossoctl#600, rossoctl#615), 0044 (rossoctl#563), 0045 (rossoctl#620) - 0046 (phase 1: rossoctl#630, rossoctl#641, rossoctl#646; phase 2 owed) - 0047 (M1 and M3: rossoctl#704, rossoctl#713, rossoctl#717, rossoctl#765; M2 owed) - 0048 (rossoctl#706, rossoctl#763, rossoctl#802, rossoctl#808, rossoctl#814; off by default until the security review's lease sections are signed off) The README index follows, and its 0033 row, which still said Proposed after rossoctl#249 accepted the ADR, is corrected. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Docs and agent-facing text that the code no longer matches, found by an issue triage against main: - The microVM guest and the SBX sandbox have no network device, but reach the hosts on moca-egress's allowlist through the host's proxy (P4.1 #581-#583; SBX egress #641/#646). Concepts, guides, P4-ON-P6, the VM README, research-smoke, hardening, maturity, the demo's limits, the SBX user guide and direct-client doc said "no network" outright. So did the sandbox MCP instructions, the tool descriptions and the sbx status text agents read, which made agents refuse allowlisted calls (#779). - openapi.yaml said the worker enforces a turn's caps; nothing does yet (#391). - harness-openapi.yaml called /turn and /runs "deliberately not described", while change-policy decision 3 makes them supported aliases (#507). - The changelog is now the API changelog for both documents, with an index of the data-plane versions; both OpenAPI files point at it, and change-policy decision 5's follow-up is done (#511). - upgrades.md and change-policy: the configRef ordering only matters from before v0.5.0 or for a bundle-format change (#512, #510). - dispatch-archetypes and maturity: deploy/k8s's async drain is proven by its smoke claims (#688, #765). - Specs: slice 3's relay restart is graceful since #462 (#453); MI1 §2.2 gains a status note for the scrub (#350) and the vsock hop. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
What
This is chunk 4, the last chunk of the SBX0.2b plan. It covers deployment, the user client, and docs for user-scoped egress credentials (spec
docs/specs/2026-10-26-sbx-egress-credentials-design.md, ADR-0046, phase 1). The control plane (#630) andmoca-egress(#641) are already onmain. This PR wires them into a deployable feature.Off by default. If
SBX_EGRESS_CREDENTIALSis unset,setup.shoutput is byte-identical to today, and a golden-file test asserts that. A host stays as it is untilinstall-host.sh --egressruns.Changes
build-snapshot.sh --egress-ca PATHbakes the host's interception CA into the golden snapshot. Only the public cert goes in, as one certificate. A file containing a private key is refused before anything is staged.update-ca-certificatesorupdate-ca-trust.NODE_EXTRA_CA_CERTS,SSL_CERT_FILEandREQUESTS_CA_BUNDLE. If the line the script anchors on ever drifts, the build fails loudly.manifest.jsongainsegress_ca_sha256, a DER digest kept outsidehash.install-host.shgains three modes:--egress BUNDLEgenerates the per-host CA once (P-256, key mode 0600). It installs amoca-egressdrop-in that loadsegress-token,egress-ca.crt,egress-ca.keyandegress-api-ca.crtthroughLoadCredential=and setsMOCA_EGRESS_CREDENTIALS_URL. The token never appears in argv or logs.--egress-ca-outprints the CA path forbuild-snapshot.sh.--uninstall-egressremoves the drop-in and the token but keeps the CA.Once credentials are on, installing a worker refuses any snapshot whose CA fingerprint doesn't match.
--egressrefuses amoca-egress.servicethat P6 owns.setup.sh, plus the kustomize Componentdeploy/k8s/overlays/ocp-sbx/egress-credentials/, both behindSBX_EGRESS_CREDENTIALS=1:sbx-egressSecret holds the KEK and oneSH_EGRESS_TOKEN_<ID>per host. Each is generated once and kept, and a host that is dropped loses its token.SH_EGRESS_HOSTSmust name template workers only, and the TTL is configurable.Recreate,SH_CREDENTIAL_STORE=file, andsbx-egressprojected into/run/credentials.mocactl sbx credentials:list,presets,add NAME --preset github|github-mcp(token on stdin),add NAME --host host[:port][/prefix] [--kind], anddelete.src/sbx/presets.ts.sbx up's agent steering now saysGH_TOKENis a placeholder.Docs:
Implemented (phase 1). Its §4.3 now names thesbx-egressSecret, and §8 lists the accepted risks: an upstreamSet-Cookie, and an endpoint that echoes headers.A0 (plan Task 1): passed, 2026-10-28
These checks used a fine-grained PAT against a private repo:
/userwith Basicx-access-token:<PAT>git ls-remotewith Basic/repos/…/pullswith Basicapi.githubcopilot.comMCPinitialize, Bearer,--http1.1serverInfoSo
githubis a single Basic credential andgithub-mcpships.Tests
install-host.test.sh,setup.test.sh(also run withMOCA_REQUIRE_WORKSPACE=1),overlay.test.shandbuild-snapshot.test.shpass.mocactlsbx-credentialsandsbx-presetstests pass.-x -S warning, Prettier andcheck-doc-links.pyare clean.Each task had its own independent review. A whole-branch review on the most capable model then traced every seam against
main: the bundle, install-host,LoadCredentialandconfig.go; the fingerprint; the control-plane boot; and themocactlbody against the server. It found three operational gaps, which were fixed in 7c76de6 and re-reviewed:Live acceptance (plan Task 15): passed 2026-10-28, single user
See the PR comment for the full results. In summary:
/user, MCP);401);401after the TTL);TestGateCredentialNeverInGuestpasses.The second-user check (acceptance item 3) was skipped by the operator and is pending.
Assisted-By: Claude Code