Feb 19, 2026 · 7 min read

Docker Sandboxes for Untrusted Code

dockersecuritysandbox

The problem

If your product executes user-submitted code, the default threat model is “they own the machine.” Sandboxing is not optional.

Isolation layers

On BugRank, a submission roughly:

  1. Writes sources into a unique working directory (UUID)
  2. Compiles/runs as an unprivileged executor user
  3. Enforces wall-clock time (~5s) and memory (~256 MB)
  4. Collects stdout/stderr and never promotes the process

Failure modes

  • Infinite loops → hard kill on timeout
  • Memory spikes → cgroup / memory limits
  • Network exfiltration → deny egress for the runner when you can
  • Shared state → never reuse dirty workspaces

Sandboxes are never “done.” Treat every new language runtime as a new attack surface.

The best security feature of a code-runner is what it refuses to share with the host.

Read on Medium