Part 10 of 13 · 2 min read
Mistakes that leave the sandbox with a hole
Common mistakes, and what the example does not do.
Mistakes that leave the sandbox with a hole
startswithpath checks without resolving.shell=Truewith model-generated text.- Inheriting the parent environment, including secrets.
- Only a timeout (no memory or file limits) or only CPU limits.
- Open network from the sandbox.
- Shared long-lived sandboxes that keep state between users.
- Mounting the host home or Docker socket into the container.
- Validating a URL once and following redirects blindly.
- Treating rlimits as isolation.
What the example does not do
About this example What the example does not do
- No container, VM, seccomp or network namespace; only argument checks and process limits.
- Linux only, and
RLIMIT_ASbehaves differently across systems and runtimes. - No limit on process count (a fork bomb is a real risk; the example deliberately did not run one) and no CPU-time accounting for child processes of the child.
- No TOCTOU defence, no redirect or DNS-rebinding handling, no Unicode or case-folding attacks on paths and hosts beyond what the tests show.
- Hand-written, small attack lists; passing them is not proof of safety.
- Optional real experiment: run the same probes inside a container with
--network none,--read-only,--pids-limitand--memory, and compare.
Check yourself
A path check uses startswith(root). What can still escape?
Show answer
A prefix collision such as ../work-evil, and symlinks. It wrongly allowed 80 percent of the 10 escape attempts; realpath plus commonpath allowed none and still accepted all 6 legitimate paths.
For the curious Limits are not isolation
CPU, memory, file and time limits stop denial of service; the infinite loop was killed after 1.02 s by a 1 s CPU limit. But a limited process can still read any file its user can and open network connections. Only a boundary (container, microVM, separate user, no network) stops data access. Layers 1 and 2 were tested on Linux; container and network isolation were not built, and the check-then-use race is not handled.
What you will use daily at work
| Practice | What it looks like |
|---|---|
| Validate paths and URLs first | Resolve symlinks, then check inside the root. |
| Set CPU, memory, file size and wall-clock limits | Plus a clean environment with no inherited secrets. |
| Run model-written code in a boundary | Container or microVM, read-only root, no host mounts. |
| Deny network by default | Allow only listed destinations. |