# What structural signals indicate a seccomp-mediated MCP sandbox has silently degraded to advisory enforcement **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that isolate untrusted MCP servers via seccomp-bpf (or equivalent syscall-filter) profiles combined with namespace isolation. Does not apply to pure capability-token sandboxes (e.g., WASM `wasmtime` fuel metering) where syscall filtering is intrinsic to the execution model rather than bolted on via `prctl`/`seccomp()` filters. ## Core Distinction The failure we care about is not "the sandbox blocked a call it should have allowed" (a false positive, noisy but safe) nor "the sandbox allowed a call it should have blocked" in the trivial sense of a missing rule. It is **silent degradation of enforcement mode**: the filter remains installed and returns success on `seccomp(SECCOMP_SET_MODE_FILTER, ...)`, yet the kernel is running the filter in a mode where violations produce `EPERM`/`ENOSYS` on the *calling thread* rather than `SIGSYS` termination, or the filter was installed with `SECCOMP_FILTER_FLAG_TSYNC` absent so only the initial thread is covered while `pthread_create`'d worker threads inherit an empty filter set. The MCP server keeps running, keeps answering `tools/call` requests, and the orchestrator's health probe (which only checks JSON-RPC liveness) reports green. The structural distinction: **a seccomp sandbox has two independent state bits — "filter installed" and "filter enforced on this thread" — and the second is per-thread, not per-process.** Any signal that only observes the first bit is structurally incapable of detecting degradation. ## What Was Observed A filesystem-read MCP server (`fs-mcp`, a Python subprocess launched via `uv`) was wrapped in a seccomp profile permitting `read`, `write`, `openat`, `close`, `mmap`, `exit_group`, and the `rt_sig*` family, denying `execve`, `socket`, `connect`, `clone` with `CLONE_NEW*`, and `ptrace`. The launcher installed the filter with: ``` prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); // note: flags == 0 ``` `flags == 0` means no `SECCOMP_FILTER_FLAG_TSYNC`. The launcher installed the filter on the main thread only. Python's `asyncio` event loop then called `loop.run_in_executor(...)` for blocking file I/O, which spawned a `ThreadPoolExecutor` worker via `pthread_create`. **New threads do not inherit seccomp filters.** The worker thread ran with an empty filter set. The observable trace: a `tools/call` for `read_file` on a path under `/proc/self/...` succeeded and returned content from a path the profile was supposed to deny (because the deny rule targeted `openat` on the main thread, but the worker's `openat` was unfiltered). No `SIGSYS`, no error, no log line. The health probe (`ping` → `pong`) returned in 3ms throughout. The only signal was a *latency asymmetry*: filtered syscalls on the main thread returned `EPERM` in ~40µs, while the same logical operation on a worker thread returned real data in ~200µs. The orchestrator had no metric for "syscall returned real data where a deny rule existed," because it had no model of which syscalls *should* have been denied. A second observed mode: when the profile was correctly TSYNC'd but the violation action was `SECCOMP_RET_ERRNO | EPERM` instead of `SECCOMP_RET_KILL_PROCESS`, a compromised server could `while(1) { syscall_denied(); }` and observe that the errno was *consistently* `EPERM` rather than the `ENOSYS` a genuinely absent syscall would produce — a fingerprint confirming a filter is present, which is a reconnaissance oracle. The server then used an allowed syscall (`mmap` with `PROT_EXEC`) to stage a payload, since `mmap` was in the allowlist for the JIT. ## Condition of Validity The invariant that must hold for the sandbox to be *actually* enforcing: > For every thread `t` that can execute a syscall on behalf of the MCP server, and for every syscall `s` not in the allowlist, `t`'s seccomp filter state must be non-empty and must map `s` to `SECCOMP_RET_KILL_PROCESS` (or `SECCOMP_RET_TRAP` with a handler that terminates). "Installed on the main thread" is not sufficient; "enforced on every thread that can reach the kernel" is required. This is valid only when: (a) the filter was installed with `SECCOMP_FILTER_FLAG_TSYNC`, *or* the runtime guarantees no thread creation after install (rare for Python/Node MCP servers, which use thread pools), *and* (b) the violation action is process-terminating, not errno-returning, *or* the runtime treats any errno-returning violation as a fatal sandbox breach and kills the server out-of-band. If the server is allowed to continue after an errno-returning violation, the errno itself becomes an oracle and the condition is void. ## Decision Boundary The boundary is between **advisory enforcement** (filter present, violations observable to the sandboxed process, process survives) and **terminating enforcement** (violations kill the process, no oracle). The structural signals that distinguish them, in order of reliability: 1. **Thread count vs. filter coverage.** If `/proc//task/` shows more threads than the launcher's install-time thread count, and the install used `flags == 0`, enforcement is advisory on the extra threads. This is a *static* check, not a runtime probe — it can be run before the first `tools/call`. 2. **Violation action class.** Grep the profile for `SECCOMP_RET_ERRNO`; any occurrence on a syscall the server can reach means the server can distinguish "filtered" from "absent" and adapt. `SECCOMP_RET_KILL_PROCESS` is the only action that closes the oracle. 3. **Health-probe semantics.** If the liveness probe is a JSON-RPC round-trip that does not itself exercise a denied syscall, it cannot detect degradation. A probe that *intentionally* issues a denied syscall and asserts `SIGSYS`/process-death is the only probe with detection power. 4. **Latency cliff.** A 5–10× latency difference between "denied" and "allowed" paths on the same logical operation is the runtime signature of a filter that is present but not terminating (errno path is fast; real syscall path is slow). This is a weak signal alone but corroborates (1) and (2). The decision: **if signal (1) or (2) fires, treat the sandbox as absent and refuse to dispatch `tools/call` to that server.** Do not attempt to "re-install" the filter at runtime — the server has already executed unfiltered code and its state is untrusted. ## Operational Effect The orchestrator must maintain a per-server **enforcement attestation** that is established at launch and re-verified on every thread-count change. Concretely: the launcher records `(install_flags, violation_action, initial_thread_count)` and the supervisor polls `/proc//task/` count; a delta without a corresponding `SECCOMP_FILTER_FLAG_TSYNC` re-install (which is impossible after the fact) is a hard failure. The MCP server is killed, the `tools/call` in flight is failed with a `SandboxDegradedError`, and the server is not restarted into the same slot — it requires a fresh launch with a corrected profile. The cost is a small number of false kills when a server legitimately scales its thread pool; the alternative is a silent advisory sandbox that answers `pong` while reading `/proc/self/mem`. ```python import os import signal import subprocess from dataclasses import dataclass class SandboxDegradedError(RuntimeError): """Raised when a seccomp sandbox has silently degraded to advisory enforcement.""" @dataclass(frozen=True) class EnforcementAttestation: install_flags: int violation_action: str # "KILL_PROCESS", "ERRNO", "TRAP", ... initial_thread_count: int def assert_terminating_enforcement( pid: int, attestation: EnforcementAttestation ) -> None: # Signal (2): errno-returning violations are an oracle, not enforcement. if attestation.violation_action != "KILL_PROCESS": raise SandboxDegradedError( f"pid {pid}: violation action is {attestation.violation_action!r}; " "server can distinguish filtered from absent syscalls and adapt" ) # Signal (1): thread-count growth without TSYNC means new threads are unfiltered. task_dir = f"/proc/{pid}/task" try: current_threads = len(os.listdir(task_dir)) except FileNotFoundError: raise SandboxDegradedError(f"pid {pid}: task dir vanished mid-attestation") if current_threads > attestation.initial_thread_count: tsync = attestation.install_flags & 0x08 # SECCOMP_FILTER_FLAG_TSYNC if not tsync: raise SandboxDegradedError( f"pid {pid}: {current_threads} threads vs " f"{attestation.initial_thread_count} at install, no TSYNC; " "worker threads run unfiltered" ) def guarded_dispatch(pid: int, attestation: EnforcementAttestation, call) -> object: assert_terminating_enforcement(pid, attestation) try: return call() except SandboxDegradedError: # Fail closed: kill the server, do not restart into the same slot. os.kill(pid, signal.SIGKILL) subprocess.run(["true"]) # placeholder for slot invalidation hook raise ```