Skip to main content

Runbook: Governed code-execution sandbox substrate (WR2-3 Slice 2)

Owner: DevOps Engineer · Refs: LLD #2184 §2/§3, HLD #2113 §2/§3 (founder security review PASSED), milestone #28 · Task: #2187

This runbook covers the SUBSTRATE the SandboxRunner seam (#2188) runs on: the gVisor RuntimeClass + pod template, the forced-proxy egress topology, the docker-compose dev equivalent, and the fail-closed proof.


1. What this is (and is not)​

  • Is: the isolation + egress substrate — RuntimeClass, ephemeral pod template, the forced egress-proxy, NetworkPolicies, and the dev-box equivalent.
  • Is not: the Go SandboxRunner / code_exec provider (#2188), the workspace store (#2185), or the security-assertion suite (#2191). This slice delivers what those run on.

2. The load-bearing invariant (HLD Finding A)​

There is no code path in which a sandbox reaches the network without an allow decision, because the network is unreachable by construction otherwise.

Enforcement is at the network boundary, not the Go http.RoundTripper (GetEgressTransport is invisible to raw sockets inside agent code). A sandbox pod runs with no default route and no DNS; a NetworkPolicy permits egress ONLY to its forced proxy on 3128, which it reaches through a launcher-pinned hostAliases entry (§10.3). (Before S6b-3, core#4637, the rule was "DNS + the forced proxy on 3128"; §6's Flaw-1 narrative is that history.) Every failure mode (proxy down, misconfigured, allowlist error) collapses to no egress — fail-closed by topology, the anti-WF-30 design.

3. Components​

ComponentProd (GKE)Dev (docker-compose)
IsolationruntimeClassName: gvisor (GKE Sandbox)runtime: runsc if present, else runc fallback
No-route netnsper-pod netns + sandbox default-deny + per-type NetworkPolicy: egress to the forced proxy only, no DNS (§10)sbx-internal network (internal: true)
Forced proxyegress-proxy Deployment (squid, default-deny)sbx-egress-proxy container (same squid.conf shape)
Allowlist DATAtenant_egress_allowlist patterns -> /etc/squid/allowlist.txt (per-run grant)dev/sandbox/allowlist.txt
Deny CIDRsdeny.go two tiers (floor + RFC1918)floor only (see §5)
Resource boundspod resources.limits (cpu/mem/ephemeral-storage/pids) + activeDeadlineSecondscpus/mem_limit/pids_limit/tmpfs; served launcher sessions: hard-TTL timer + disk poll of /work+/tmp
Who creates sandboxesthe sandbox-launcher service in-cluster under its own SA, with a Kubernetes backend (S6 #4637, principal-architect Q1 = B); the orchestrator uses SANDBOX_SUBSTRATE=remotethe sandbox-launcher service — the ONLY holder of /var/run/docker.sock (founder ruling 4; core#4632). The orchestrator calls it over upsquad.sandbox.v1.LauncherService with SANDBOX_SUBSTRATE=remote and holds no socket and no docker CLI. See sandbox-launcher.md.
Platform tier(S6)dev/sandbox/conf.d/20-platform-tier.conf — model-gateway:8091, context-engine:8080, GET/POST only, then a dotless deny; docker-compose.sandbox.platform.yml gives the proxy its one upsquad-dev leg

Files:

  • deployments/sandbox/base/ — RuntimeClass, the sandbox and sandbox-egress namespaces, the sandbox-pod ServiceAccount, ResourceQuota, the xfs StorageClass, the sandbox pod ValidatingAdmissionPolicy, both proxies (egress-proxy, coder-egress-proxy), NetworkPolicies. See §10.
  • deployments/sandbox-launcher/base/ — the in-cluster launcher (§10).
  • deployments/sandbox/overlays/{dev,prod}/ — dev = the substrate only, floor-only, single proxies, NO launcher; prod = the substrate AND the launcher, HA proxies (2 + PDB each), RFC1918 private-deny injected into egress-proxy, RuntimeClass removed (Autopilot-managed), cluster addresses from Pulumi.prod.yaml.
  • deployments/sandbox/templates/sandbox-pod.yaml — the per-run-step Pod the runner (#2188) stamps out. NOT a standing object (excluded from kustomize).
  • dev/sandbox/ + docker-compose.sandbox.dev.yml — dev topology.
  • scripts/sandbox-egress-smoke.sh — the fail-closed proof (since core#4632 also through the real launcher: docker-compose.sandbox.smoke.yml, P0–P12).
  • cmd/sandbox-launcher, deployments/sandbox-launcher/Dockerfile, internal/workflow/sandbox/launcher_*.go, remotelauncher.go — the launcher service and its client (core#4632).

The docker substrate is dead configuration on compose. The orchestrator container has no socket (asserted by scripts/check-sandbox-launcher-compose.py), so SANDBOX_SUBSTRATE=docker there can only fail at the first launch; the dev default is remote. The in-process docker launcher remains for a single-process developer run and for the existing unit tests; S3 may delete it.

4. runsc-on-devbox feasibility​

Update 2026-11-22 (S6, core#4637 / #4638): runsc is MEASURED, and the proxy address is pinned.

  • Name resolution under gVisor. Docker's embedded DNS (127.0.0.11) is iptables DNAT inside the container's network namespace. gVisor's netstack never sees that rule, so under runsc no container NAME resolves; this is why the proxied arms were 18/34 on runsc. Every sandbox therefore reaches the forced proxy through one hosts entry, egress-proxy -> 10.247.0.10, and nothing else is in its hosts file.
    • sbx-internal declares a literal subnet: 10.247.0.0/24 with ip_range: 10.247.0.128/25. Dynamic leases come only from the range, so they can never take the proxy's pinned .10.
    • The proxy holds ipv4_address: 10.247.0.10. Compose probe sandboxes get it via extra_hosts; launched sandboxes get it via a launcher-chosen --add-host (SANDBOX_LAUNCHER_PROXY_HOST/_ADDR/_SANDBOX_SUBNET, config only).
    • At startup the launcher refuses to serve unless docker network inspect shows the network internal, with exactly that subnet, and the container at the address answering to egress-proxy.
    • scripts/check-sandbox-launcher-compose.py S12 asserts all of it and refuses $ in any ipam value.
    • Overlapping subnets: measured on the dev box (docker 29.5.2) a second network with an explicit overlapping subnet is REFUSED ("Pool overlaps", or "networks have overlapping IPv4" with an ip_range). backend-security measured a daemon that accepted one (#4688 N8), so the guard is not compose: it is the launcher's startup check (the network's exact subnet and the container holding the pinned address answering to egress-proxy). Practical consequence on the dev box: a scratch SANDBOX_SMOKE_PROJECT smoke cannot create its sbx-internal while the dev sandbox stack holds the subnet — run scratch smokes with the dev sandbox stack down.
  • Operator step on a box where upsquad-sandbox-dev_sbx-internal already exists with the pre-S6 dynamic subnet (172.19.0.0/16 on the dev box): see sandbox-launcher.md §3a "Dev roll". Since the S6 follow-ups the dev deploy brings the sandbox stack up itself; the operator only removes the old network once.
  • The runtime is measured, not declared.
    • Under SANDBOX_RUNTIME=runsc the launcher runs a canary (dmesg | head -1; cat /proc/version in the probe image). It serves only if the canary shows gVisor's boot banner and kernel string. Measured on runsc release-20261116.0: [ 0.000000] Starting gVisor... / Linux version 4.19.0-gvisor #1 SMP Sun Jan 10 15:06:54 PST 2016. runc with cap-drop ALL cannot read dmesg at all.
    • SANDBOX_LAUNCHER_ENFORCE_RUNTIME=true refuses runc before touching the daemon. It also reads HostConfig.Runtime back from the daemon for every container before anything runs in it: batch is create -> inspect -> start -a; served is create -> inspect -> start (PA #4688 F1: never run -d under enforce, so a mismatched container never runs its entrypoint).
    • The smoke takes the runtime from docker info of the daemon in use. When runsc is claimed and absent, the smoke FAILS. It adds the BANNER, DNS0 (no external name resolves), DNS1 (proxy -> pinned address), ENF0 and ENF1 arms.

Update 2026-11-20 (core#4632): docker info on the devbox now lists a runsc runtime (/usr/bin/runsc); scripts/sandbox-egress-smoke.sh detects it and uses it unless SANDBOX_SMOKE_RUNTIME=runc forces the fallback. The launcher refuses to start if SANDBOX_RUNTIME names a runtime the daemon does not have, and reports the one it uses through GetRuntime, so the orchestrator's AssertRuntime (SANDBOX_ENFORCE_RUNTIME) applies to the remote launcher exactly as to the in-process one. The paragraph below is the original (pre-runsc) record.

runsc is NOT installed on the current devbox (only runc; no /dev/kvm, so Firecracker is also out — consistent with HLD §2). The dev fallback (LLD §2.3) therefore runs: the governed path is identical — netns-no-route + forced proxy + cgroups + cap-drop + non-root + read-only-root + RuntimeDefault seccomp. Only the kernel-isolation strength downgrades (userspace-kernel gVisor -> host-kernel runc). The smoke prints a loud WARN and treats it as sandbox_degraded. To run the prod-faithful path on a runsc-capable box:

# install runsc + register the docker runtime, then:
SANDBOX_RUNTIME=runsc bash scripts/sandbox-egress-smoke.sh

Config assertion (owned by #2188): the gvisorRunner MUST refuse to start in CI/prod when the resolved runtime is not runsc (assert on SANDBOX_RUNTIME/RuntimeClass), so the degraded fallback can never run outside a developer box. This substrate surfaces the signal; the runner enforces it.

5. Prod-vs-dev delta (and why dev is still prod-faithful)​

The only substantive delta is the RFC1918 private-CIDR deny:

  • SSRF FLOOR (neverOverridableCIDRs in internal/mcp/egress/deny.go: metadata 169.254.0.0/16, loopback, link-local, 0.0.0.0/8) — enforced identically in dev + prod (squid ssrf_floor ACL, denied first).
  • RFC1918 (overridableCIDRs: 10/8, 172.16/12, 192.168/16, fc00::/7) — prod only (overlays/prod injects 10-private-deny.conf into squid conf.d). Dev omits it because dev upstreams legitimately live on the docker RFC1918 bridge. This mirrors deny.go's own ADR-0025 allow_private in-cluster-upstream override — dev is exactly the "reach an in-cluster upstream on a private IP" case that tier is designed to permit.

Everything else — no-route topology, forced-proxy default-deny, allowlist DATA plumbing, cap-drop/non-root/read-only/seccomp/pids/cpu/mem bounds — is byte-identical in shape. Only the pod-create vs docker-run launch call differs, and that is isolated in the runner's platform adapter (#2188).

6. Fail-closed proof (run it)​

bash scripts/sandbox-egress-smoke.sh

Asserts (exit 0 iff ALL hold):

#TestExpect
P0direct dial to a public IP (no proxy)blocked — no route
P1direct dial to metadata 169.254.169.254blocked — no route
P2proxied + allowlisted hostHTTP 200
P3proxied + non-allowlisted hostHTTP 403 (default-deny)
P4proxied + metadata IPHTTP 403 (SSRF floor)

Serve-mode preview (LBE slice 1, #2239 — the architect Flaw-1 correction)​

The same script ALSO runs the P0–P4 proof from a preview-sandbox-labeled pod (the serve-mode sibling) plus a router-reachability check, so a preview pod's egress is proven byte-for-byte the batch posture:

#TestExpect
PP0preview pod direct dial to a public IPblocked — no route
PP1preview pod direct dial to metadatablocked — no route / lateral+metadata
PP2preview pod proxied + allowlisted hostHTTP 200 — it reaches the forced proxy
PP3preview pod proxied + non-allowlistedHTTP 403 (default-deny)
PP4preview pod proxied + metadata IPHTTP 403 (SSRF floor)
PP5served whoami dialed from a router-net container on $PORTHTTP 200 — reachable in-network

Why PP2 is the Flaw-1 assertion (GKE-only): on GKE, a preview pod is labeled upsquad.io/component: preview-sandbox (so the batch NetworkPolicy's ingress: [] stays untouched). But the forced-proxy's own ingress policy (egress-proxy-netpol, deployments/sandbox/base/networkpolicy.yaml) previously admitted only code-exec-sandbox on 3128 — a preview-sandbox pod could not reach the proxy AT ALL (fail-closed, but its egress was fully blocked, not "identical to batch"). This slice amends egress-proxy-netpol to admit preview-sandbox too (shared egress infra — the one deliberate touch), and adds preview-sandbox-netpol.yaml (ingress from the preview-router on $PORT; egress = DNS + 3128 only). PP2 is the assertion that would have caught the gap. The dev-box caveat: docker egress is network-membership-based (both sandbox types join sbx-internal), not label-selector-based, so the compose stack was never affected — the gap was GKE/prod-only.

Last local run (runc fallback, sandbox_degraded=1) — batch P0–P4 + preview PP0–PP5:

PASS: P0 direct public IP blocked (no route): [000 rc=7]
PASS: P1 direct metadata IP blocked (no route): [000 rc=7]
PASS: P2 proxied allowlisted host allowed: HTTP 200
PASS: P3 proxied non-allowlisted host denied: HTTP 403
PASS: P4 proxied metadata IP denied (SSRF floor): HTTP 403
PASS: PP0 preview direct public IP blocked (no route): [000 rc=7]
PASS: PP1 preview direct metadata IP blocked (no route): [000 rc=7]
PASS: PP2 preview reaches forced proxy for allowlisted host: HTTP 200
PASS: PP3 preview proxied non-allowlisted denied: HTTP 403
PASS: PP4 preview proxied metadata IP denied (SSRF floor): HTTP 403
PASS: PP5 served whoami reachable from router-net container on $PORT: HTTP 200
==> RESULT: 11 passed, 0 failed
==> FAIL-CLOSED PROOF: OK

Serve-mode CLI smoke (slice-1 acceptance, no proxy needed)​

cmd/preview-serve-smoke is the standalone Go caller of the ServiceRunner seam — NewGVisorServiceRunner → StartService (launch + readiness) → ProbeService (liveness) → StopService (idempotent teardown) — over the dev docker ServiceLauncher, using buildDockerArgs verbatim (the served whoami runs the IDENTICAL hardening as a batch run; only the launch shape is detached):

go run ./cmd/preview-serve-smoke \
-network upsquad-sandbox-dev_sbx-internal \
-image traefik/whoami:v1.10.2 -args "--port,8080"

Last local run (runc fallback, sandbox_degraded=1):

PASS: became ready at sbx-prev-...:8080 (runtime=runc degraded=true)
PASS: liveness probe reports the service live
PASS: stopped cleanly
PASS: re-stop is idempotent
==> SERVE-MODE SMOKE: OK

CI: .github/workflows/sandbox-egress-smoke.yml runs P0–P4 (+ preview PP0–PP5) on every PR touching the substrate (non-authoritative — no runsc on GH runners; #2191 adds the authoritative gVisor gate on a runsc-capable runner).

The HLD's P1 netns-escape / P2 proxy-down / P3 DNS-rebind pen-tests are hardened further by QA in #2191; this script is their seed.

7. Validate the manifests​

# The render suite + its mutation battery (needs kustomize + PyYAML):
bash tests/scripts/test_sandbox_k8s_render.sh
# NetworkPolicy peers, namespaces and the reach matrix (§10.4):
python3 scripts/check-netpol-reachability.py
# Schema (ExternalSecret is a CRD; kubeconform needs its schema or a skip):
kustomize build deployments/sandbox/overlays/prod | kubeconform -strict -summary -skip ExternalSecret
kustomize build deployments/sandbox/overlays/dev | kubeconform -strict -summary -skip RuntimeClass
kubeconform -strict deployments/sandbox/templates/sandbox-pod.yaml
docker compose -f docker-compose.sandbox.dev.yml config

8. Deploy / rollback (prod)​

Deploy is GitOps via ArgoCD (never kubectl apply by hand). Point an ArgoCD Application at deployments/sandbox/overlays/prod. Rollback = revert the commit; ArgoCD syncs the prior revision (< 5 min). Because egress is fail-closed by topology, a partial/failed sync degrades to no egress, never to open egress.

9. Secrets​

No secrets enter the sandbox (HLD §3.3). As amended by S6 (#4637, ADR-0037 D4), there is no in-sandbox credential for materialisation: the per-run object-store signer that once filled this role is gone, and the sandbox-launcher refuses workspace_signer (ErrWorkspaceSignerRefused). The launcher streams the work tree into the pod. The only secret a pod receives is a coder session's single-use relay secret, delivered over the authenticated init stream into a memory-medium file (S6b-2), never through a manifest here. The forced proxy holds no tenant credentials; it consults allowlist DATA only.

10. The Kubernetes layout (S6b-3, core#4637)​

The k8s backend of the sandbox-launcher (SANDBOX_LAUNCHER_BACKEND=k8s, S6b-1/S6b-2) runs in-cluster as the ONLY creator of sandbox pods. Nothing here runs on dev: dev keeps the compose launcher with the docker backend, and the render suite fails if any compose file or any overlays/dev directory selects k8s.

10.1 Namespaces​

NamespaceHoldsPSA (enforce / audit / warn)
sandboxthe ephemeral sandbox pods ONLY; the sandbox-pod ServiceAccount (no binding, no token, no Workload Identity); the launcher's Role + RoleBinding; a ResourceQuota; NetworkPolicies. No Secret, no standing workload.restricted / restricted / restricted
sandbox-egressegress-proxy (batch + preview; tenant grant) and coder-egress-proxy (the Model Gateway only)restricted ×3 (S6b-4: squid runs as its own uid 13 with no added capability and max_filedescriptors 65536; proven Ready with no restart on kind)
sandbox-launcherthe launcher Deployment (1 replica, Recreate), its ServiceAccount (the only token-bearing pod in these namespaces), Service :9480, two ExternalSecrets, the image-allowlist ConfigMaprestricted ×3

Every namespace has a default-deny NetworkPolicy (podSelector: {}, both directions). Cross-namespace peers name the namespace by kubernetes.io/metadata.name and the pods by label in one peer element.

10.2 Who may reach what​

FromToPortWhy
orchestrator (platform; app: agent-orchestrator or app: agent-runtime, component: orchestrator)launcher9480LauncherService (TLS 1.3, SPKI pinned)
launcherpods in sandbox labelled upsquad.launcher=19000ws-receive (the tree)
launcherkube-system53resolve github.com
launcherthe control-plane endpoint (prod: Pulumi.prod.yaml controlPlaneCidr)443the apiserver. On GKE the kubernetes Service address is translated before policy applies, so the rule names the endpoint CIDR. The base names TEST-NET-1 (192.0.2.1/32): the base alone cannot reach an apiserver and the launcher refuses to start.
launcher0.0.0.0/0 minus private, loopback, link-local, CGNAT443GitHub. Recorded residual: any public address on 443 (GitHub's ranges are not pinned).
batch / preview podegress-proxy3128the only egress; no DNS
coder podcoder-egress-proxy3128the only egress; no DNS; never the tenant proxy
preview-router (P2)preview pod8080served port. Same-namespace peer today, so it selects nothing — a router cannot run in sandbox (the VAP admits only the three sandbox pod types). P2 re-homes the router and this peer together.
agent-runtime worker (platform)coder pod8080the coder relay
egress-proxypublic 80/443 (no RFC1918/metadata), kube-system 53allowlisted origins (the squid ACL is the per-run control)
coder-egress-proxyModel Gateway pods (platform) 8091, kube-system 53the platform tier only

The platform ends of these flows are in place too (landed with S6b-3, core#4637, outside these directories): deployments/model-gateway/base/network-policy.yaml admits coder-egress-proxy from sandbox-egress on 8091; the orchestrator's egress (deployments/agent-orchestrator, deployments/agent-runtime) allows the launcher on 9480; and the agent-runtime worker's egress allows launched coder pods in sandbox on 8080. The reach matrix renders both ends of each flow and proves the allow and its negatives (scripts/check-netpol-reachability.py).

10.3 How a pod reaches its proxy without DNS​

Each proxy Service has a fixed spec.clusterIP — base 10.96.0.240 / 10.96.0.241 (kind's default service range), prod 10.22.0.240 / 10.22.0.241 (inside Pulumi.prod.yaml servicesCidr 10.22.0.0/20). All four sit in the low 1/16th of the service range, which the apiserver reserves for static assignment (KEP-3070), so no dynamic Service can take them first. The launcher reads them as SANDBOX_LAUNCHER_K8S_EGRESS_PROXY_ADDR / SANDBOX_LAUNCHER_K8S_CODER_PROXY_ADDR and pins hostAliases: egress-proxy -> <ip> (or coder-egress-proxy) into each pod, the k8s counterpart of compose's --add-host egress-proxy:10.247.0.10. In prod the env values are COPIED from the rendered Services by kustomize replacements, so they cannot differ; the render suite asserts equality in every render that holds both.

10.4 The admission policy​

deployments/sandbox/base/validating-admission-policy.yaml binds every pod CREATE/UPDATE (and pods/ephemeralcontainers) in sandbox, for every requester, failurePolicy: Fail, validationActions: [Deny]. One validation per rule, message sandbox-pod-policy/<rule-id>: ... (53 rules; the ids are listed in EXPECTED_VAP_RULES in tests/scripts/sandbox_k8s_render_cases.py). Since S6b-4: dns-policy admits dnsConfig.options exactly {timeout:1, attempts:1} (the renderer's; musl waits out its whole timeout even on a refused query); image-digest's name part is [^@]+, so x@sha256:<64>@sha256:<64> is refused; and the three resource rules read resources through dyn(), because the apiserver's typed Pod schema gives a Quantity map no CEL type (every static limits/requests reference was a status.typeChecking warning on kind; vap_cel_typecheck_test.go reproduces the warning against a typed Pod slice and holds the rules to zero). It sees the pod after mutating admission, so it admits exactly the tolerations two built-in plugins add (DefaultTolerationSeconds' not-ready/unreachable; the gvisor RuntimeClass's sandbox.gke.io/runtime=gvisor). container-count fixes the pod's shape: exactly one main container and exactly the init containers ws-receive, ws-observe, in that order (a webhook that injects a sidecar is refused). Requires Kubernetes >= 1.30. In every k8s backend test the fake apiserver's admission hook is this policy's own CEL (cel-go, internal/workflow/sandbox/vap_cel_helpers_test.go); the Go oracle in podspec_admission_test.go is a cross-check held to it rule by rule.

10.5 How pins, TLS and the agent image are supplied​

  • Images: every rendered image is @sha256:<64 hex>. squid is pinned to the digest measured from the registry. The launcher and workspace-agent images carry the 64-zero placeholder (unpullable, so fail-closed) until a promotion pins published digests; the render suite holds placeholders in prod to an explicit register. The workspace-agent image is set in TWO places that a promotion changes together — SANDBOX_LAUNCHER_WORKSPACE_AGENT_IMAGE and the sandbox-launcher-images allowlist (asserted). Sandbox pods may not use imagePullSecrets (VAP), so runtime and agent images must be pullable by the node identity (Artifact Registry), not private GHCR.
  • TLS: ExternalSecret sandbox-launcher-tls (gcp-secret-store; remote keys sandbox-launcher-tls-cert / -key) produces a kubernetes.io/tls Secret in sandbox-launcher, mounted read-only at /etc/upsquad/tls. Rotation: add the next SPKI pin to the orchestrator, rotate the secret, restart the launcher.
  • Caller authentication: ExternalSecret sandbox-launcher-caller — the platform signing key's PUBLIC half plus kid / issuer / base URL, from the same store the orchestrator's values come from.

10.6 What S6b-4 (kind) must prove​

The render suite and the reach matrix are static. On a kind cluster with the VAP enabled, S6b-4 must show, per item, by observation:

  1. a pod the launcher renders is ADMITTED, runs under gVisor and completes;
  2. each VAP rule REJECTS its own mutation, asserted by its message. The per-container rules (image digest, runAsNonRoot/User/Group, privilege escalation, privileged, capabilities, read-only root, seccomp, SELinux/AppArmor, procMount, hostPort, envFrom, env valueFrom, mount propagation, volumeDevices, probes, lifecycle, limits and their ceilings) apply to EVERY container list: containers, initContainers and ephemeralContainers. Each is rejected on each list (on ephemeralContainers alongside no-ephemeral-containers), as TestVAPCEL_PerContainerRulesHoldOnEveryContainerList asserts statically;
  3. the launcher's ServiceAccount is refused everything outside its Role (watch, patch, exec, attach, portforward, ephemeralcontainers, secrets);
  4. the reach matrix holds on the wire (allows connect; every negative times out);
  5. a batch pod resolves no name and reaches its proxy through hostAliases;
  6. the coder proxy forwards to the Model Gateway and refuses everything else;
  7. the launcher refuses to start with the base's TEST-NET-1 apiserver rule;
  8. the startup canary's live denial message names sandbox-pod-policy/runtime-class (the launcher refuses to serve on a denial by any other rule). MARGIN: k8sapi keeps only the first 256 bytes of a Status.message, and the match needs denied request: sandbox-pod-policy/runtime-class: inside them. In the apiserver's format (pods "<name>" is forbidden: ValidatingAdmissionPolicy '<policy>' with binding '<binding>' denied request: <message>) at the shipped names (a 43-byte canary name, policy and binding both sandbox-pod-policy) the anchor ends at byte 195: a 61 B margin. A binding name of up to 79 bytes fits; every byte of a longer configured policy name costs two (it is named twice), so SANDBOX_LAUNCHER_ADMISSION_POLICY fits up to 48 bytes with the shipped binding. Since S6b-4 the launcher checks this AT CONSTRUCTION (checkCanaryAnchorFits): it takes the binding's name from SANDBOX_LAUNCHER_ADMISSION_BINDING (default: the policy's name), computes the anchor's end at the canary's fixed 43-byte name, and refuses to start, naming k8sapi's 256-byte cut and the longest binding/policy name that fits, when the anchor would be cut (ErrK8sCanaryAnchorCut). A denial cut at run time still fails closed. The kind run measured the live anchor at byte 195, the value the construction check computes. TestK8sBackend_AdmissionCanaryAnchorSurvivesTruncation holds the shipped margin at >= 32 B and shows the cut one byte past the longest binding. The kind run records the LIVE message's length and anchor offset against this;
  9. measure containerLogMaxSize on the target and set SANDBOX_LAUNCHER_K8S_CONTAINER_LOG_MAX_BYTES (G4). Done on kind (S6b-4): /configz reports containerLogMaxSize: 10Mi, containerLogMaxFiles: 5; the Deployment declares 10485760 and the render test and the kind-proof checker pin it to that measurement. GKE Autopilot's value is S6b-5's to measure;
  10. close G9 (batch stdout read through pods/log under log rotation). Closed in S6b-4 with closure (c), a worst-case line bound that fits one log file. The launcher reads a batch log as at most cap+1 bytes (one past the cap marks an over-cap log). The worst case on the node per byte read back is an EMPTY line: one \n behind a CRI prefix of at most 48 bytes, so 49 bytes. The kubelet rotates a file only once it has reached containerLogMaxSize, and only while the container runs, so the launcher refuses (at construction for SANDBOX_LAUNCHER_MAX_OUTPUT_BYTES, and per request) any cap with (cap+1) x 49 + 111 >= SANDBOX_LAUNCHER_K8S_CONTAINER_LOG_MAX_BYTES (ErrK8sStdoutExceedsLogMax; 111 B is the anchor line below). At 10485760 the largest batch stdout cap is 213991 B (about 209 KiB: (213991+1) x 49 + 111 = 10485719); the Deployment ships 204800 (200 KiB). The launcher's 1 MiB default, and an org policy asking for more than the ceiling, are refused on k8s (fail closed, by name). A step far past its cap that keeps running is DETECTED, fail closed (S6b-4 round 3). Measured before: 400000 empty lines then sleep 25 read back as 0 bytes, exit 0, no error — the kubelet's rotation pass had moved the whole file away and the log API returns only the newest one. Now every k8s batch pod's main container runs /run/upsquad-anchor/sandbox-stdout-anchor --line=<anchor> -- <entrypoint...> (cmd/sandbox-stdout-anchor, ~1.5 MB static, copied by ws-receive from the workspace-agent image into the 4Mi memory ws-anchor emptyDir, mounted read-only in the main container). It writes upsquad-sandbox-stdout-anchor:<32 hex> (a per-pod crypto/rand nonce in its argv only, which the exec replaces) as the log's first line and execs the step. The kubelet rotates only the OLDEST bytes away, so a log that does not begin with that exact line had its start rotated away: the run fails with ErrK8sStdoutRotated (resource_exhausted on the wire), whatever the exit status, and returns nothing; on a timeout, eviction or deadline the rotated stdout is dropped and the termination reason stands. Consequence: a k8s batch run must name its entrypoint (ErrK8sEntrypointRequired; the launcher cannot read an image's ENTRYPOINT). Residual: a step that has the nonce could forge the line, and it cannot read it (no pod-spec access, the argv is replaced); the anchor costs ~1.5 MB of the pod's memory (the emptyDir).

Items 11, 13, 14 and 16 below, and item 15 for kind, are now measured on kind (S6b-4, §10.7); item 12 and the GKE values remain S6b-5's. As first written: not executed anywhere yet, and each is a named gate on core#4637 (the render suite, the CEL test and the reach matrix cannot show any of them):

  1. CEL cost budget. The real apiserver accepts the policy within its per-expression and per-policy CEL cost limits, typed from the Pod schema (the CEL test types object as dyn and stands in for the quantity library, so it cannot measure cost);
  2. mutation order vs the policy (GKE). On the GKE target, the pod the policy sees after GKE's own mutating admission (the RuntimeClass plugin's gVisor toleration and nodeSelector, DefaultTolerationSeconds, Priority, and any GKE-added mutating webhook) is still admitted: a rendered pod is admitted and the canary is denied by runtime-class only. kind does not run GKE Sandbox's mutations, so this is the GKE run, not the kind run;
  3. exec readiness under gVisor. ws-observe's exec readiness probe runs under runsc and gates pod Ready within the probe timeout (a probe that cannot exec in the sandbox would hold every preview pod un-Ready);
  4. DNS fails fast, not slow. A lookup in a batch pod is refused promptly by the loopback nameserver, not answered after the resolver's timeout and retries. Measure it with each libc resolver a tenant image may carry: glibc, and musl (whose resolver can take ~10 s before giving up). Record the observed latency and the image's resolver with the result;
  5. the real containerLogMaxSize (item 9) is measured on the target, not assumed;
  6. the G6 gVisor measurements recorded in the core#4637 register (among them the coder tier's 65534/65534 with OnRootMismatch, and ws-observe's 65533) are taken on a runsc node, and G7, the launcher's own scratch bound (MAX_SESSIONS x (input + workspace) against the workspace emptyDir sizeLimit), is observed live, eviction included.

10.7 What S6b-4 proved on kind (and what it did not)​

scripts/sandbox-k8s-kind-proof.sh RECEIPTS_DIR creates one throwaway kind cluster (guards: >= 6 GiB MemAvailable, >= 20 GiB disk, no Deploy Dev Stack in flight; the node bounded to 8 GiB / 6 CPUs with kubelet eviction, reservations and maxPods 30; the kind network only; only 127.0.0.1:6443 published; runsc mounted read-only; unconditional teardown) and writes one JSON receipt per row with raw evidence. scripts/check-sandbox-k8s-kind-proof.py RUN_DIR validates a run and fails closed (every row required; B and G4 cross-checked against this tree's Deployment). Run it from a copy of the tree if you may edit the tree meanwhile (bash reads a script as it runs). The receipts of record are the coordinator's, on core#4637.

RowWhat it shows, live
Arunsc on kind: a gVisor pod's dmesg banner and /proc/version differ from runc's.
B/configz: containerLogMaxSize 10Mi, containerLogMaxFiles 5; a RUNNING writer's log is rotated away, an exited one's is not.
Cthe policy and binding applied with zero status.typeChecking warnings; every rendered pod admitted; the canary denied by runtime-class, anchor at byte 195 (the construction check's number); container-count refuses an injected sidecar and reordered init containers.
Dwith the renderer's resolver config: glibc getent fails in <= 0.1 s; one musl getaddrinfo in ~1 s (was 5 s); musl-utils getent hosts (two calls) in ~2 s (was 10 s); busybox nslookup at once.
Eboth proxies Ready, 0 restarts, for >= 5 min under PSA restricted with no added capability; restricted refuses a proxy pod that adds SETUID/SETGID.
G1-fullthe 77-case reach matrix planned from check-netpol-reachability.py (by import) onto real labels and namespaces, plus the 5 forced-proxy Service cases: every live case as the matrix says (ALLOW and DENY), each DENY to a bare address with a reachability precondition. Not expressible on kind, with the reason recorded: the 4 metadata-server cases (nothing answers 169.254.169.254), and every case whose endpoint the live VAP refuses to create (rogue, preview-router in sandbox).
G2-rulesall 53 rules' witnesses on the real apiserver, PSA on and off, the answering layer recorded per witness (rule id, PSA, validation, RuntimeClass/Priority plugin, decode). Every rule has an exact live denial except privileged and no-volume-devices, which no valid pod reaches first (validation or an earlier rule answers; the set is held exactly). no-ephemeral-containers is reached through pods/ephemeralcontainers on an UNSCHEDULED pod: on a scheduled pod every UPDATE is refused first by no-node-name. The 13 witnesses PSA answered first are each denied by the policy alone.
G2-cel-costthe largest rendered pod and a worst case (250 annotations, 124 volumes, ~400 env and ~123 mounts per container) admitted with no CEL cost error.
G4the launcher refuses to start at an output ceiling one byte past G9's bound, (logMax-1-111)/49 (logged ErrK8sStdoutExceedsLogMax); declared outputs come back whole after ws-observe exits.
G9-rotation(round 3, from the E2E run) two steps write 770000 empty lines (~30 MiB on the node, three log files) and sleep past the 10 s rotation pass, one also printing a tail after it: both FAIL with ErrK8sStdoutRotated (resource_exhausted, 0 bytes, exit 0 not reported), the launcher logs sandbox_batch_stdout_rotated for each, the at-cap run is still read whole, and a run with no entrypoint is refused.
G6under runsc: ws-observe's uid 65533 reads the tree through gid 65534 and cannot write /work (read-only mount); /work is 0:65534 3777; ws-observe gets SIGTERM after main exits and exits 0; a setsid and a nohup child of main cannot write /work after main exits; the real exec readiness probe holds Ready until the server answers; the agent's extraction and refusal tests pass and its banner, O_PATH, openat, readlinkat and symlinkat paths work.
G74 x (16 + 112) MiB in a copy of the launcher's workspace volume is not evicted; the sizeLimit + 1 MiB is. Fixed here: at exactly 512 MiB of data in the old 512Mi volume the pod WAS evicted (filesystem overhead), so the volume is now 576Mi (64 MiB headroom, asserted). Round 3: the batch-input and acquired-tree caps now count a file's DISK cost, ceil(size/4096) x 4096 + 512 B (scratchFileBytes, scratchPerFileOverheadBytes = 512: the mkfs.xfs v5 default inode size, which also covers ext4's 256; directories and symlinks charged the 512 alone), not its content bytes, so a tree of many tiny files cannot overrun the volume behind a content-byte cap; 20000 one-byte files' measured du is under their charge. These are assumptions about the target filesystem: S6b-5 re-measures the real-xfs worst case.
G8the coder volume's 20Gi bound (admitted at 20Gi, refused at 20Gi + 1 byte); exec probes admitted, httpGet/tcpSocket/grpc refused. xfs: deferred to S6b-5 (no PD CSI and no unprivileged loop provisioner on kind).
E2Ethe real launcher Deployment (BACKEND=k8s, ENFORCE=true, TLS, pins, images built from the tree) serves, through the real VAP, PSA and NetworkPolicies and measured as gVisor: a batch run with inputs and declared outputs, the largest input tree (256 files of 60 KiB, 15728640 B, charged 15859712 B under G7's block accounting; ws-observe's walk+hash ends ~1 s after main, inside the 30 s grace), G9's stdout at the cap (read whole) and one over (reported over), the G9-rotation steps, and a preview Ready through ws-observe's exec probe. Fixed here: the Deployment's SANDBOX_LAUNCHER_WORKSPACE_ROOT was the emptyDir's root, which the launcher (uid 65534) cannot chmod; it is now a subdirectory (asserted).

Still S6b-5 (GKE, founder-gated): Dataplane V2 enforcement, GKE Sandbox and Autopilot mutations versus the policy (item 12), Autopilot's real containerLogMaxSize, PD CSI xfs and its quota, the metadata-server denials, Artifact Registry pulls by node identity and Workload Identity.

RESIDUALS recorded by S6b-4 round 2, and what round 3 did with them: (1) G9 — a step far over its cap that keeps running past a rotation pass was read short (measured: 400000 empty lines then sleep 25 read as 0 bytes, exit 0). Closed by detection: the stdout anchor (item 10); such a run now fails by name (row G9-rotation). (2) G7 — the launcher's caps counted tree CONTENT bytes while the kubelet counts disk usage. Closed by accounting: the caps count ceil(size/4096) x 4096 + 512 B per file (row G7); the block size and the 512 B per-file overhead are assumptions S6b-5 re-measures on the real xfs target. Still open there: a directory's own blocks are not charged (the 64 MiB headroom covers them), and an acquired workspace's git directory is not counted against MAX_WORKSPACE_MIB (a --depth 1 fetch of the same tree).