Repository navigation
fix(sandbox): refuse docker-in-sandbox where admission forbids it - #619
Conversation
A docker_enabled sandbox gets a privileged docker:dind sidecar. On a kubernetes backend whose sandbox namespace enforces any Pod Security Standard — Baseline included — Pod Security Admission rejects that Pod outright, so the workload can never run: for an environment the PVC is created first and the Deployment then loops on FailedCreate (privileged), for a conversation the Job's Pod is never created. Make the capability explicit instead of discovering it from admission: - agent-runner: SANDBOX_DOCKER_IN_SANDBOX (default true) gates the kubernetes backend's DinD sidecar, and Start/CreateEnvironment/ StartEnvironment return an actionable error before any API write. - api: the same variable is reported as docker_in_sandbox on GET /environments/config. - web: the environment-create and agent docker toggles stay hidden when that is false.
The Kubernetes backend's DinD sidecar is privileged, so a sandbox namespace enforcing Baseline cannot run a docker_enabled sandbox at all. Give the chart a value for it and set SANDBOX_DOCKER_IN_SANDBOX on both agent-runner (which enforces it) and api (which reports it on GET /environments/config).
There was a problem hiding this comment.
Important
apps/web/src/components/projects/environments/environment-create-dialog.tsx fails biome check, which is exactly the bun run lint step in web-pr-ci — CI will be red on this PR. Details inline. The rest of the change is sound: the agent-runner gate covers every workload-creating path before any write, and the API/helm/web wiring is consistent.
Reviewed changes — reviewed the deployment-level docker-in-sandbox gate end to end: the agent-runner refusal, the API config field and GET /environments/config, the helm wiring, the web toggle-hiding, and the new test.
- agent-runner gate —
SANDBOX_DOCKER_IN_SANDBOX(defaulttrue) flows toManager.dockerInSandbox;requireDockerInSandboxAllowedrefuses adocker_enabledsandbox inStart,CreateEnvironment, andStartEnvironmentbefore any clientset write. - API surface —
DockerInSandboxparsed with the same permissive fallback as agent-runner, exposed asdocker_in_sandboxonGET /environments/config. - Helm —
agentRunner.sandbox.dockerInSandboxwired into both the agent-runner and api Deployments; README andvalues.yamlupdated. - Web — the environment-create dialog and both agent docker toggles are hidden when
docker_in_sandbox === false, with an "older APIs" fallback that keeps them visible. - Test —
TestDockerInSandboxDisabled_RefusesBeforeSubmittingAnythingcovers all three entry points and asserts zero Jobs/Deployments written.
ℹ️ The setting does not remediate already-running privileged Deployments
The flag only changes what agent-runner submits from now on. A docker-enabled environment created before the operator sets dockerInSandbox: false keeps its existing Deployment (still carrying the privileged dind sidecar), and the Kubernetes Deployment controller keeps recreating that Pod on eviction or node drain — with no agent-runner involvement. The new README text explains how to stop new docker sandboxes but does not tell the operator that pre-existing docker-enabled environments must be deleted for the namespace to be free of privileged Pods.
Technical details
# Non-retroactive docker-in-sandbox flag
## Affected sites
- `services/agent-runner/internal/sandbox/k8s/dind.go:82` — `dockerInSandbox` is read only here; nothing scales down or deletes an already-created Deployment.
- `services/agent-runner/internal/sandbox/k8s/environment.go:291` — `buildEnvironmentDeployment` sets `Replicas: 1`, so a pre-existing docker-enabled Deployment keeps a live privileged Pod independent of agent-runner.
- `deploy/helm/README.md:69-74` — added text covers refusal of new sandboxes only.
## Required outcome
- Documentation (README / `values.yaml` note) should state that existing docker-enabled environments must be deleted for a namespace to be free of privileged Pods after flipping the flag.
## Open questions for the human
- Should the change actively tear down/reconcile pre-existing privileged environment Deployments, or is documenting the manual cleanup sufficient?deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…ale values note - environment-create-dialog: reindent the wrapped docker block (biome check formatting, i.e. web-pr-ci's lint step). - agent-detail: keep the toggle visible when the agent already has docker_enabled, so an existing agent can still switch it off. - values.yaml/README: the flag is not retroactive, and the sidecar note no longer claims there is nothing to configure.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — reviewed the 956983f..48b95b9 delta: the web docker-toggle conditions, the environment-create-dialog wrapper re-indent, and the helm docs rewrite. No Go changes in this range, and the three prior Pullfrog threads are all addressed.
- Re-indented the docker-toggle block —
environment-create-dialog.tsx's wrapped block now matchesbiome's indentation;biome check .passes over all 617 files inapps/web, so theweb-pr-cilint step is green. - Kept the agent docker toggle reachable —
agent-detail.tsxnow renders the switch whendockerInSandbox || dockerEnabled, so an agent already atdocker_enabled: truecan still turn docker off.create-agent-dialog.tsxis unchanged and safe here since new agents default tofalse. - Corrected the stale and incomplete docs — the
values.yaml"nothing to configure here" note now points atdockerInSandbox, and both it and the README state the flag is not retroactive (a pre-existing docker-enabled environment keeps its privileged Pod until deleted).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Symptom
Creating an environment (or running an agent conversation) with
docker_enabledon the Kubernetes sandbox backend never starts a Pod, and the failure does not name the real cause:Deployment.apps "paca-env-<id>" is invalid: spec.template.spec.containers[1].securityContext ... cannot set allowPrivilegeEscalation to false and privileged to true(a platform policy adding privilege-escalation hardening to the privileged sidecar — that one is fixed separately), and once past it,FailedCreate ... forbidden: violates PodSecurity "baseline:latest": privileged (container "dind" must not set securityContext.privileged=true)on a ReplicaSet retry loop, while the environment's PVC is already created and the row sits increatinguntil it times out.Every Pod Security Admission level except
privilegedforbids a privileged container, so on a deployment whose sandbox namespace enforces Baseline — the leveldeploy/helm/README.mddocuments as the strictest the Kubernetes backend supports — adocker_enabledsandbox is un-runnable. Nothing in the API, the UI, or agent-runner knows that, so the operator gets minutes of retry loop and an error about a field pair rather than "this deployment cannot run docker".Fix
Make the capability a first-class deployment setting, default-on so existing deployments are unchanged:
SANDBOX_DOCKER_IN_SANDBOX(defaulttrue) on agent-runner gates the Kubernetes backend's DinD sidecar.Start,CreateEnvironmentandStartEnvironmentrefuse adocker_enabledsandbox before any API write, with an error that names the cause and the way out.docker_in_sandboxonGET /environments/config, which is already public and already the frontend's source for deployment-wide environment facts.false, so the setting is not offered where it cannot work.Refusing before the write also removes the leaked-PVC state: today a failed create leaves its PVC behind and the row at
errorwith nobackend_ref, so it can be neither started nor retried.Verification
services/agent-runner:go build ./...,go vet ./..., fullgo test $(go list ./... | grep -v /test/e2e)pass.services/api: same three gates pass.TestDockerInSandboxDisabled_RefusesBeforeSubmittingAnythingcovers all three entry points and asserts the refusal text plus zero Jobs/Deployments written.return nil, the same test fails withStart error = sandbox/k8s: no pod matching selector "job-name=paca-sbx-…" got an IP after 1ms … want the docker-in-sandbox refusal (not a readiness failure)— i.e. it submits the workload again, exactly the reported behaviour.apps/webhas nonode_moduleshere, so notsc -pand no component test. The four touched files parse underesbuild --loader:.tsx=tsx;biome@2could not install its native CLI in this environment, andbiome@1flags import order on untouched files too, so it is not a usable signal.Notes
docker_enabledgets the same refusal, immediately.Closes #618.