fix(sandbox): harden sandbox containers against privilege escalation
Summary
Four targeted container hardening changes for issue #337.
Important clarification (flagged by code review): no-new-privileges alone does not close the Docker socket escape vector — an attacker with socket access can ask the host daemon to launch a privileged container regardless of this flag. The changes here are genuine defense-in-depth, but the definitive fix for #337 remains DOCKER_INSIDE=false or fronting the socket with a least-privilege proxy. Issue #337 should stay open until that is addressed.
Changes
backend/pkg/docker/client.go — RunContainer hardening
no-new-privileges:true: prevents setuid/setgid and file-capability escalation inside the containerPidsLimit=2048: fork-bomb / resource exhaustion guard- Startup warning: logrus.Warn when DOCKER_INSIDE=true so operators see the socket-escape risk at boot
- Comment corrected: no longer implies no-new-privileges mitigates the #337 socket escape (it doesn't)
backend/pkg/tools/tools.go — CapDrop ALL
Drop all Linux capabilities, add back only NET_RAW + optionally NET_ADMIN. Removes ~14 unnecessary caps (SYS_CHROOT, AUDIT_WRITE, MKNOD, etc.) from the default Docker set.
.env.example
- Flip DOCKER_INSIDE default from true → false (aligns with config.go envDefault:"false")
- Expand comment with socket-escape risk, DinD guidance, docker-socket-proxy link
What is NOT addressed (why #337 stays open)
The root cause — a process in the sandbox can POST to the Docker socket to launch a privileged container with the host filesystem mounted — is not addressed by these changes. Definitive mitigations are: DOCKER_INSIDE=false, a socket proxy, or rootless/sysbox DinD. This PR does the hardening safe to ship immediately while that architectural question is resolved.
Testing
go build ./pkg/docker/... ./pkg/tools/...— cleango test ./pkg/docker/... ./pkg/tools/...— all pass