Skip to content

docker_enabled sandboxes cannot run when the sandbox namespace enforces PodSecurity Baseline #618

Closed

Description

@kayahk

Symptom

Creating an environment (or running an agent conversation) with docker_enabled on the Kubernetes sandbox backend never starts a Pod, and the failure does not name the real cause:

  • environment: 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 in creating until it times out.
  • conversation: the Job is created, its Pod never is.

Every Pod Security Admission level except privileged forbids a privileged container, so on a deployment whose sandbox namespace enforces Baseline — the level deploy/helm/README.md documents as the strictest the Kubernetes backend supports — a docker_enabled sandbox 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 (default true) on agent-runner gates the Kubernetes backend's DinD sidecar. Start, CreateEnvironment and StartEnvironment refuse a docker_enabled sandbox before any API write, with an error that names the cause and the way out.
  • The same variable is read by the API and reported as docker_in_sandbox on GET /environments/config, which is already public and already the frontend's source for deployment-wide environment facts.
  • The environment-create dialog and both agent docker toggles are hidden when it is 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 error with no backend_ref, so it can be neither started nor retried.

Verification

  • services/agent-runner: go build ./..., go vet ./..., full go test $(go list ./... | grep -v /test/e2e) pass.
  • services/api: same three gates pass.
  • New TestDockerInSandboxDisabled_RefusesBeforeSubmittingAnything covers all three entry points and asserts the refusal text plus zero Jobs/Deployments written.
  • Sabotage check: with the guard stubbed to return nil, the same test fails with
    Start 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.
  • Web: apps/web has no node_modules here, so no tsc -p and no component test. The four touched files parse under esbuild --loader:.tsx=tsx; biome@2 could not install its native CLI in this environment, and biome@1 flags import order on untouched files too, so it is not a usable signal.

Notes

  • Enforcement stays in agent-runner, which is the layer that knows the backend; the API field exists so the UI can hide the toggle, not as a second gate. An API-only caller that still sets docker_enabled gets the same refusal, immediately.
  • A deployment that wants docker-in-sandbox needs a sandbox namespace whose Pod Security Admission allows privileged Pods — a deliberate, node-level trust decision this change does not make for anyone.

Activity

  1. pullfrog commented on Oct 21, 2026

    @pullfrog
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions