Secure, Fast, and Extensible Sandbox runtime for AI agents.
fix(env): read the MITM CA lineage from platform.egressMitmCA
高然649f9e6c64af
diff --git a/scripts/fast-sandbox-env/README.md b/scripts/fast-sandbox-env/README.mdindex 5b1b1e29a..13857a8ab 100644--- a/scripts/fast-sandbox-env/README.md+++ b/scripts/fast-sandbox-env/README.md@@ -11,10 +11,10 @@ The `verify-native` / `verify-overlaybd` actions drive the server through the opThe environment exercises the full MITM trust-anchor chain against the real components — no simulation:1. **CA material** — a self-signed CA (fresh per run) is provisioned as the versioned Secret `opensandbox-mitm-ca-v1` in the dataplane namespace, per the ops-runbook shape collapsed into one namespace: keypair entries (`tls.crt` + `tls.key`) for the egress seed mount, certificate-only entry (`ca.crt`) for the template bake. The stored certificate is fingerprint-checked against the generated one (content, not name).-2. **Template bake** — the rendered server `config.toml` sets `kubernetes.template_mitm_ca_secret`, so the server fills `spec.egressMitmCertificate` on the template create and the builder installs the certificate into the guest trust store, stamping `lineage.egressMitmCA.certSha256` into the published artifact manifest. The template stage asserts the CR field and the lineage fingerprint.+2. **Template bake** — the rendered server `config.toml` sets `kubernetes.template_mitm_ca_secret`, so the server fills `spec.egressMitmCertificate` on the template create and the builder installs the certificate into the guest trust store, stamping `platform.egressMitmCA.certSha256` into the published artifact manifest. The template stage asserts the CR field and the lineage fingerprint.3. **Pool pinning** — the pool's egress container mounts the Secret read-only as its CA seed; the MITM addon starts with the pinned CA (fail-closed, never generates) and exposes its fingerprint on `/healthz`. The pool stage asserts the fingerprint equals the pinned one.4. **Injection e2e** — a dedicated verify stage creates a sandbox with a policy allowing the CA-signed TLS echo endpoint (a container on the kind network reflecting request headers), first proves the credential-free passthrough (no `X-Api-Key`), then binds a vault credential to the SNI (`X-Api-Key` via the relay) and asserts the guest's own `curl --resolve … https://echo.test` response reflects the injected header — TLS verified against the template-baked CA on every leg, no `-k` anywhere. A pause/resume round trip then repeats the request: trust and vault travel with the snapshot.-5. **Pinning assertion** — template manifest lineage fingerprint == egress `/healthz` fingerprint == the pinned Secret's fingerprint, asserted three-way.+5. **Pinning assertion** — template manifest `platform.egressMitmCA` fingerprint == egress `/healthz` fingerprint == the pinned Secret's fingerprint, asserted three-way.Requires a bare-metal Linux host with KVM (`/dev/kvm`), Docker, Go ≥ 1.25, cgroup v2, and `sudo` for the XFS StateRoot loop mount and sysctl bump. The CLI install requires `uv` (it manages its own ≥ 3.10 interpreter), or set `OSB_BIN` to a preinstalled `osb` binary. Full operational notes (topology, latency characteristics, production caveats): `fast-sandbox/docs/guides/firecracker-integration-env.md`.diff --git a/scripts/fast-sandbox-env/integration-env.sh b/scripts/fast-sandbox-env/integration-env.shindex c71592497..8deb83a0c 100755--- a/scripts/fast-sandbox-env/integration-env.sh+++ b/scripts/fast-sandbox-env/integration-env.sh@@ -1513,7 +1513,7 @@ template_up() {|| fail "template CR egressMitmCertificate.key is '$cert_key', want ca.crt (certificate entry only)"lineage_fp="$(template_mitm_lineage_fingerprint)"[[ "$lineage_fp" == "$MITM_CA_FINGERPRINT" ]] \- || fail "template manifest lineage egressMitmCA.certSha256 is '${lineage_fp:-empty}', want pinned $MITM_CA_FINGERPRINT"+ || fail "template manifest platform.egressMitmCA.certSha256 is '${lineage_fp:-empty}', want pinned $MITM_CA_FINGERPRINT"log "template baked CA: secret/$cert_ref (ca.crt), lineage fingerprint ${lineage_fp:0:16}…"pass "SandboxTemplate Succeeded + artifacts published (via opensandbox CLI)"return 0@@ -1815,16 +1815,16 @@ bake_registry_ca_into_images() {verify_image_ca_bake "$IMG_RUNTIME"}-# template_mitm_lineage_fingerprint [template-id] -> the egressMitmCA.certSha256-# the builder stamped into the published artifact-set manifest (empty when the-# manifest or the lineage entry is missing).+# template_mitm_lineage_fingerprint [template-id] -> the certSha256 the+# builder stamped under platform.egressMitmCA in the published artifact-set+# manifest (empty when the manifest or the entry is missing).template_mitm_lineage_fingerprint() {local tid manifest_ref manifest_jsontid="${1:-$TEMPLATE_ID}"manifest_ref="$(osb_api template get "$tid" -o json 2>/dev/null | jq -r '.status.manifest_ref // empty')"[[ -n "$manifest_ref" ]] || return 0manifest_json="$(rc cat "chain/$RUSTFS_BUCKET/$(dirname "${manifest_ref#s3://$RUSTFS_BUCKET/}")/manifest.json" 2>/dev/null)" || return 0- printf '%s' "$manifest_json" | jq -r '.lineage.egressMitmCA.certificates[0].certSha256 // empty' 2>/dev/null+ printf '%s' "$manifest_json" | jq -r '.platform.egressMitmCA.certificates[0].certSha256 // empty' 2>/dev/null}# --- stage: SandboxPool (egress attached, P2P spread) --------------------------------------------@@ -2748,15 +2748,15 @@ mitm_ca_chain_verify() {# Optional template override (the overlaybd second pass); default native.local template_id="${1:-$TEMPLATE_ID}"local created sandbox_uid ack echo_secret- log "verify (mitm-ca): three-way fingerprint pinning (template lineage == egress /healthz == pinned Secret)"+ log "verify (mitm-ca): three-way fingerprint pinning (manifest platform.egressMitmCA == egress /healthz == pinned Secret)"local healthz_fp lineage_fphealthz_fp="$(egress_mitm_ca_fingerprint)"[[ "$healthz_fp" == "$MITM_CA_FINGERPRINT" ]] \|| fail "mitm-ca verify: egress /healthz fingerprint is '${healthz_fp:-empty}', want pinned $MITM_CA_FINGERPRINT"lineage_fp="$(template_mitm_lineage_fingerprint "$template_id")"[[ "$lineage_fp" == "$MITM_CA_FINGERPRINT" ]] \- || fail "mitm-ca verify: template manifest lineage fingerprint is '${lineage_fp:-empty}', want pinned $MITM_CA_FINGERPRINT"- pass "template↔pool CA pinning: manifest lineage == egress /healthz == pinned (${MITM_CA_FINGERPRINT:0:16}…)"+ || fail "mitm-ca verify: template manifest platform.egressMitmCA fingerprint is '${lineage_fp:-empty}', want pinned $MITM_CA_FINGERPRINT"+ pass "template↔pool CA pinning: manifest platform.egressMitmCA == egress /healthz == pinned (${MITM_CA_FINGERPRINT:0:16}…)"# Sandbox policy: the domain allow covers the vault binding (binding# validation requires the host be policy-allowed), the IP allow covers