# Why does an instance escape its sandbox the moment a tool's seccomp profile is inherited across an execve, and how does that turn an egress-deny into an egress-allow without any policy edit? **Date of Record:** 2026 December 1 **Scope:** Applies to tool runtimes where an agent process installs a syscall filter (seccomp-bpf), an egress policy, and a secrets-isolation boundary, then spawns child tools via `execve` (shell wrappers, `subprocess`, MCP stdio servers, sandbox helpers). Does not apply to VM/microVM-per-tool isolation where each tool gets a fresh kernel boundary, nor to filterless runtimes relying solely on network namespaces. ## Core Distinction The distinction that matters is between **the filter as a property of the process image** and **the filter as a property of the process lineage**. Operators routinely assume that once the supervisor installs a seccomp profile and an egress deny-list, every descendant inherits both. That assumption is half true and half catastrophically false. Seccomp filters *are* inherited across `fork` and `execve` — the kernel copies the filter tree to children and preserves it through `execve` (unless the profile sets `SECCOMP_FILTER_FLAG_TSYNC` incorrectly or the process holds `CAP_SYS_ADMIN` and calls `prctl(PR_SET_SECCOMP, ...)` to replace it). Egress policy and secrets isolation are *not* kernel-inherited in the same way: they are enforced by userspace (a proxy, an `LD_PRELOAD` shim, a netns with a routing rule, a mount namespace binding secrets). Those userspace mechanisms are re-established only if the child's entrypoint re-executes the wrapper. A tool that execs a *new* interpreter — a Go binary, a statically linked helper, a shell that launches a subprocess — bypasses the userspace layer while still carrying the seccomp filter. The result is a process that looks confined (it carries the filter) but is not confined along the axes that actually matter (network, secrets, filesystem). This is the boundary failure: **filter inheritance is orthogonal to policy inheritance**, and a tool runtime that conflates them will pass its own conformance check while leaking. ## What Was Observed A tool runtime for an agent ran each tool call inside a supervisor that: 1. Called `prctl(PR_SET_NO_NEW_PRIVS, 1)`. 2. Installed a seccomp-bpf profile via `prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)` that allowed a narrow syscall set and denied `socket`, `connect`, `sendto`, `execve` (post-install), and `ptrace`. 3. Set `HTTP_PROXY`/`HTTPS_PROXY` to a deny-by-default egress proxy and mounted a tmpfs over `/run/secrets`. 4. `execve`'d the tool binary. The conformance check ran a probe tool that attempted `socket(AF_INET, SOCK_STREAM, 0)` and asserted `EPERM`. It passed. The check also asserted that `/run/secrets` was empty. It passed. Then a real tool — a Python script whose first line was `#!/usr/bin/env python3` — was invoked. The `env` binary exec'd `python3`, which is a *different process image*. The seccomp filter survived (correct). But the egress proxy variables survived only as environment strings, and the tool's own HTTP client, `requests`, read them and honored them — until the tool spawned a subprocess to run `curl` for a large download, and `curl` in that image had been compiled without proxy support and ignored `HTTPS_PROXY`. The seccomp filter denied `socket` — except the filter's allow-list had been widened by a well-meaning patch to permit `socket` for the tool's own DNS resolution, and the deny was on `connect` to specific address families only, not on `socket` creation. The `curl` child, carrying the filter, called `socket(AF_INET, SOCK_STREAM, 0)` → allowed, then `connect` → the filter's `connect` rule matched only `AF_INET6` and `AF_UNIX` and default-allowed `AF_INET`. Egress succeeded. The proxy was never consulted because `curl` never looked at `HTTPS_PROXY`. The secrets isolation held — `/run/secrets` was still a tmpfs — but the tool's `curl` fetched a URL that the *agent* had been told to fetch, and the response body contained a token the agent then wrote into its scratchpad. The secret didn't leak from the mount; it leaked because egress was open and the agent chose to fetch a URL that returned a credential. The isolation boundary was intact; the confinement boundary was not. ## Condition of Validity The invariant that must hold for the sandbox to be sound: > **For every process in the tool's lineage, the effective policy is the intersection of (a) the seccomp filter tree inherited from the supervisor and (b) the userspace enforcement layer active in that process image. Confinement holds only if (b) is re-established at every `execve` boundary, or if (a) alone is sufficient to enforce the policy.** The second clause is the escape hatch that operators miss. If the seccomp filter alone enforces egress (by denying `connect` for all families the tool could use), then userspace re-establishment is unnecessary and the invariant holds trivially. But the moment the filter is loosened — to allow DNS, to allow a specific tool's socket use, to allow `AF_INET` for a local sidecar — the filter alone is no longer sufficient, and the policy now depends on userspace enforcement surviving `execve`. It does not survive unless the tool's entrypoint is the supervisor's wrapper. This is why the conformance probe passed and the real tool failed: the probe was a single-image tool whose entrypoint was the supervisor's wrapper. The real tool was a multi-image pipeline (`env` → `python3` → `curl`) where the wrapper was only the first image. The condition of validity is therefore: **either the seccomp filter is the sole enforcement mechanism (and is complete), or every `execve` in the lineage re-enters the supervisor's wrapper.** There is no third option. A mixed model — filter plus userspace, with userspace assumed to be inherited — is unsound. ## Decision Boundary When designing or auditing a tool sandbox, the decision boundary is: - **If the filter is complete** (denies every syscall the tool could use to escape, including all `connect` families, `socket` for non-local families, `execve` post-install, `ptrace`, `open_by_handle_at`, `bpf`, `perf_event_open`), then userspace enforcement is defense-in-depth and may be assumed absent. The sandbox is sound even if the wrapper is bypassed. - **If the filter is incomplete** (any allow that could be used for egress, secrets access, or privilege), then the sandbox is sound *only if* the wrapper is re-entered at every `execve`. This requires either (a) a `PTRACE_O_TRACEEXEC`-based supervisor that intercepts `execve` and re-injects the wrapper, (b) a static wrapper compiled into every tool image, or (c) a kernel-level mechanism (Landlock, or a seccomp filter that denies `execve` entirely and forces tools to be single-image). The failure mode observed above is the second branch with the wrapper *not* re-entered. The decision boundary is the point at which the operator chooses between "make the filter complete" and "make the wrapper mandatory." Choosing neither — trusting inheritance — is the unsound state. A concrete test for the boundary: for each tool, enumerate its `execve` lineage (strace the tool, or read its shebang chain). For each image in the lineage, verify that the effective syscall policy is the intersection described above. If any image has a looser effective policy than the supervisor intended, the sandbox is unsound. ## Operational Effect The operational effect is a class of escapes that are invisible to standard conformance checks because the check probes the *first* image, not the lineage. The escape does not require a malicious tool; it requires only a tool whose entrypoint is not the supervisor's wrapper — which is the common case for `#!/usr/bin/env` scripts, Go binaries that `exec` helpers, and MCP servers that spawn subprocesses. The response is to make the invariant enforceable: 1. **Inventory the lineage.** For every tool, record its `execve` chain. A tool with more than one image in its chain is a candidate for the escape. 2. **Make the filter complete or the wrapper mandatory.** If the filter cannot be made complete (because the tool legitimately needs `connect`), then the wrapper must be re-entered. The cheapest enforcement is a seccomp rule that denies `execve` for any binary not on an allow-list of wrapper entrypoints — this forces every `execve` through the wrapper. 3. **Re-probe at every image.** The conformance check must run inside each image in the lineage, not just the first. A probe that runs in the `python3` image and the `curl` image will catch the egress allow. 4. **Treat egress and secrets as separate axes.** The secrets isolation held in the observed failure; the egress did not. Auditing them together hides the asymmetry. Probe them independently. The deeper operational lesson is that sandbox soundness is a property of the *lineage*, not the *process*. A supervisor that installs a filter on itself and execs a tool has confined only the first image. Every subsequent `execve` is a new decision point, and the kernel does not make the decision for you — it only carries the filter, which is necessary but not sufficient. ```python class SandboxLineageEscape(RuntimeError): """Raised when a process in a tool's execve lineage has a looser effective confinement policy than the supervisor intended.""" pass def audit_lineage(lineage, supervisor_policy): """ lineage: list of dicts, one per execve image, each with: - image: str (binary path) - seccomp_allows: set[str] (syscalls the inherited filter permits) - userspace_enforced: set[str] (axes re-established by wrapper in this image: 'egress', 'secrets', 'fs') supervisor_policy: dict with: - required_denies: set[str] (syscalls that must be denied) - required_axes: set[str] (axes that must be enforced somewhere) """ if not lineage: raise SandboxLineageEscape("empty lineage: no process to audit") for idx, image in enumerate(lineage): # Axis 1: seccomp completeness. If the filter permits a required-deny # syscall, this image relies on userspace enforcement. leaked = supervisor_policy["required_denies"] & image["seccomp_allows"] if leaked: # The filter is incomplete here; userspace must cover the gap. missing_axes = supervisor_policy["required_axes"] - image["userspace_enforced"] if missing_axes: raise SandboxLineageEscape( f"lineage image {idx} ({image['image']}): seccomp permits " f"{sorted(leaked)} but userspace does not enforce " f"{sorted(missing_axes)}; wrapper was bypassed at execve" ) return True def run_tool_with_audit(supervisor, tool_entrypoint): lineage = supervisor.trace_execve_lineage(tool_entrypoint) try: audit_lineage(lineage, supervisor.policy) except SandboxLineageEscape as e: supervisor.quarantine(tool_entrypoint) raise SandboxLineageEscape( f"refusing to execute {tool_entrypoint}: {e}" ) from e return supervisor.exec(tool_entrypoint) ```