Skip to content

deploy/sbx: the host agent bakes the host's egress CA into a credentials host's egress builds - #948

Merged
pdettori merged 1 commit into
rossoctl:mainfrom
webchang:pr/i923-agent-egress-ca
Nov 20, 2026
Merged

pdettori merged 1 commit into
rossoctl:mainfrom
webchang:pr/i923-agent-egress-ca

Conversation

@webchang

Copy link
Copy Markdown
Member

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 and install-host.sh refused 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 test install-host.sh's check_snapshot_ca uses) and the claimed spec has egress: true, the build gets --egress-ca <SBX_ENV_DIR>/egress/ca.crt. A spec without egress is built as before (template-build.sh refuses --egress-ca there). 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 mirror install-host.sh's egress_dropin and EGRESS_CRED_DIR, with a comment naming them.
  • Docs: the runbook's "The template host agent" says so, and the credential-injection procedure notes that a self-serve build claimed before --egress is built without the CA and needs a rebuild.

The CA is part of a build's identity: egress_ca_sha256 is 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 as install-host.sh's for the same SBX_UNIT_DIR and SBX_ENV_DIR:

Case Before After
credentials on, spec egress: true built without --egress-ca (FAIL) built with --egress-ca <host CA>
credentials off no --egress-ca no --egress-ca
credentials on, spec egress: false no --egress-ca no --egress-ca
credentials on, no CA file built (FAIL) reported failed, step: egress

The other deploy/sbx suites pass. On a slow machine, the existing start-time assertion in host-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_ca uses at worker install, so the build and the install never disagree. Two things follow:

  • A window on a fresh host, closed by procedure. The documented order creates the CA first and installs the drop-in last, so a self-serve build claimed in between lacks the CA and is refused at worker install. The runbook's credential procedure now says to stop sbx-host-agent (or let no build be queued) from creating the CA until the drop-in is in; such a build is rebuilt.
  • A known limit (follow-up). The CA is inside the manifest hash, so a build made on one host is refused on a host with a different CA: egress builds are per host. That's the placement question deploy/sbx: the host agent never passes --egress-ca, so self-serve templates can't use egress credentials #923 raised (should placement match a build only to hosts with its CA?), left for a follow-up.
  • Every egress build trusts the host's CA. On a credentials host, every egress: true build 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

…'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]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 20, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dropin reproduces install-host.sh's own layout (moca-egress.service.d/sbx-credentials.conf under SBX_UNIT_DIR, default /etc/systemd/system) and the CA is its EGRESS_CRED_DIR/ca.crt under SBX_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 == true agrees with the tool's own test. template-build.sh:160-162 requires a boolean and refuses --egress-ca for 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" compares egress_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_claimed before the building report — the shape the gate and template-id refusals already use — with step: egress as 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---egress anchor 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.

Comment thread deploy/sbx/host-agent.sh
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pdettori
pdettori merged commit 6a4cb90 into rossoctl:main Nov 20, 2026
17 checks passed
pdettori pushed a commit that referenced this pull request Nov 20, 2026
… 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]>
pdettori added a commit that referenced this pull request Nov 20, 2026
deploy/sbx: the host agent refuses a SBX_UNIT_DIR that isn't a plain absolute path (follow-up to #948)
@pdettori pdettori added this to the v0.11.0 milestone Nov 20, 2026
webchang added a commit to webchang/moca that referenced this pull request Nov 20, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy/sbx: the host agent never passes --egress-ca, so self-serve templates can't use egress credentials

3 participants