Repository navigation
deploy/sbx: the host agent bakes the host's egress CA into a credentials host's egress builds - #948
Conversation
…'s CA when credentials are on On a host where install-host.sh --egress turned egress credentials on (its moca-egress drop-in exists), install-host.sh refuses a snapshot that does not trust the host's interception CA, but the host agent built every claimed template without --egress-ca, so a self-serve template on such a host could never get a worker. The agent now passes --egress-ca with the host's CA for a spec with egress true, and reports the build failed (step egress) when credentials are on and the CA file is missing. A spec without egress is built as before (template-build.sh refuses --egress-ca there). SBX_UNIT_DIR (default /etc/systemd/system, as install-host.sh's) locates the drop-in. Closes rossoctl#923 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review — deploy/sbx: the host agent bakes the host's egress CA into a credentials host's egress builds
Right diagnosis and the right place for the fix: the worker install refuses a snapshot that does not trust the CA (check_snapshot_ca), and the build is the only place the agent can put it.
- The same predicate the installer uses.
egress_dropinreproducesinstall-host.sh's own layout (moca-egress.service.d/sbx-credentials.confunderSBX_UNIT_DIR, default/etc/systemd/system) and the CA is itsEGRESS_CRED_DIR/ca.crtunderSBX_ENV_DIR, so "credentials are on" means exactly what it means at worker install — and the new test pins the two scripts' rendered paths against each other for the same settings, so a rename in one cannot quietly diverge. .egress == trueagrees with the tool's own test.template-build.sh:160-162requires a boolean and refuses--egress-cafor a false one, so the agent cannot pass it a combination it rejects, and cannot skip the CA for a spec that needs it.- The identity consequence is real. The version-2 manifest hash hashes
egress_ca:%s(build-snapshot.sh), and "already built" comparesegress_ca_sha256, so a CA-backed build is a new build and a snapshot with another CA (or none) is not reused — which is exactly the rebuild, rotation and per-host-placement limits the body and docs state. - The trust trade is as stated. The proxy hands a CONNECT to the interceptor only when the sandbox's owner has a credential for that host:port and tunnels everything else (
remote-worker/internal/egress), so a build trusting the CA does not let the host read traffic the owner holds no credential for. - The refusal path reuses
fail_claimedbefore thebuildingreport — the shape the gate and template-id refusals already use — withstep: egressas free text, which the control plane accepts for a claimed build. - Docs put the consequence where an operator meets it: the fresh-host procedure's window (CA created, drop-in not yet in, stop
sbx-host-agent) and the host-agent section's rebuild-on-enable-or-rotate sentence; the#credential-injection---egressanchor resolves.
The inline comment is a nit: SBX_UNIT_DIR is defaulted but never checked, while install-host.sh refuses anything but a plain absolute path for it — and a typo here reads as "credentials off", i.e. it silently rebuilds the very snapshot #923 was about.
Checks: 13 passed, 3 pending, none failing at the time of review. Author: webchang (MEMBER — maintainer). One commit, signed off.
| local t | ||
| for t in jq curl df mktemp base64 sha256sum systemctl flock; do command -v "$t" >/dev/null || refuse "needs $t on PATH"; done | ||
| SBX_SRV="${SBX_SRV-/srv/sbx}" SBX_ENV_DIR="${SBX_ENV_DIR-/etc/sbx}" | ||
| SBX_SRV="${SBX_SRV-/srv/sbx}" SBX_ENV_DIR="${SBX_ENV_DIR-/etc/sbx}" SBX_UNIT_DIR="${SBX_UNIT_DIR-/etc/systemd/system}" |
There was a problem hiding this comment.
nit. SBX_UNIT_DIR is defaulted here but never validated, while install-host.sh refuses anything but a plain absolute path for it (PLAIN_PATH_RE: install-host.sh:419, 977). A typo — a relative path, a trailing space — makes [[ -f "$(egress_dropin)" ]] read as "credentials off", so the agent builds exactly the CA-less snapshot #923 was about, and the operator only finds out when the worker install refuses it. One line beside the SBX_SRV check would close it, e.g. [[ "$SBX_UNIT_DIR" =~ $PLAIN_PATH_RE ]] || refuse ..., with the same regex copied or named.
… plain absolute path Follow-up to #948 (#923): validate SBX_UNIT_DIR with install-host.sh's PLAIN_PATH_RE, beside the SBX_SRV check. #948 defaulted it but never checked it, so a relative path or a trailing space made the credentials drop-in test read as off, and an egress template would be built without the host's CA (then refused at worker install). The regex is copied from install-host.sh, which reads the same drop-in, and the path-parity test now asserts the two are identical; the settings-refusal test covers a relative path, a trailing space and a trailing slash. Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
deploy/sbx: the host agent refuses a SBX_UNIT_DIR that isn't a plain absolute path (follow-up to #948)
Carries rossoctl#941-rossoctl#946, rossoctl#948, rossoctl#950 and rossoctl#338's rossoctl#949/rossoctl#951 (API 1.33.0). One conflict: docs/operate/sandbox-service/install.md's settings table; upstream's table kept (its rossoctl#945 SBX_STORAGE_CLASS wording, the OIDC and proxy-hop rows) plus the fork's SBX_GATE_RECORD_SCHEMA row. The fork-only set is unchanged: the same 30 files. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Summary
On a KVM host with egress credentials on, the host agent built every self-serve template without
--egress-ca, so the snapshot never trusted the host's TLS-interception CA andinstall-host.shrefused its worker ("does not trust this host's egress CA"). Self-serve templates could not use egress credentials. Closes #923.What changes
deploy/sbx/host-agent.sh: when the host's credentials drop-in exists (moca-egress.service.d/sbx-credentials.conf, the same testinstall-host.sh'scheck_snapshot_causes) and the claimed spec hasegress: true, the build gets--egress-ca <SBX_ENV_DIR>/egress/ca.crt. A spec without egress is built as before (template-build.shrefuses--egress-cathere). With credentials on and no CA file, the claimed build is reported failed (step: egress) instead of being built into a snapshot the worker install would refuse.SBX_UNIT_DIR(default/etc/systemd/system,install-host.sh's own setting and default) locates the drop-in; the paths mirrorinstall-host.sh'segress_dropinandEGRESS_CRED_DIR, with a comment naming them.--egressis built without the CA and needs a rebuild.The CA is part of a build's identity:
egress_ca_sha256is inside the version-2 manifest hash. So a build made with the CA is a new build, and self-serve egress templates a host already holds need a rebuild once credentials are turned on (or the CA rotated).Tests
deploy/sbx/tests/host-agent.test.sh, new section 3b, plus a check that the agent's drop-in and CA paths render the same strings asinstall-host.sh's for the sameSBX_UNIT_DIRandSBX_ENV_DIR:egress: true--egress-ca(FAIL)--egress-ca <host CA>--egress-ca--egress-caegress: false--egress-ca--egress-castep: egressThe other
deploy/sbxsuites pass. On a slow machine, the existing start-time assertion inhost-agent.test.sh("startSeconds":4[0-2]) can read 43-44 and fail; that's the same on main and unrelated to this change.Credentials count as on when the drop-in exists: the same predicate
check_snapshot_causes at worker install, so the build and the install never disagree. Two things follow:sbx-host-agent(or let no build be queued) from creating the CA until the drop-in is in; such a build is rebuilt.egress: truebuild now trusts that host's interception CA, including templates whose owners never store a credential. That's the intended trade: the CA's key stays on the host, and the proxy intercepts only a host:port the sandbox's owner has a credential for; everything else stays an opaque tunnel.Assisted-By: Claude Code