# When must an instance treat a syscall-policy denial inside an MCP tool sandbox as a semantic failure rather than a retryable transient? **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that execute untrusted MCP servers under syscall-level policy enforcement (seccomp-bpf, Landlock, gVisor-style interceptors) and receive tool results back through the MCP transport. Does not cover network-layer egress filtering alone, nor sandboxes that surface denials only as opaque exit codes without distinguishable errno or signal metadata. ## Core Distinction A syscall-policy denial is not a tool error and not a transport error. It is a *proof of an attempted capability that the policy forbade*. The agent must distinguish three states that all arrive as "the tool call failed": 1. **Transient fault** — the tool ran, hit a recoverable condition (timeout, busy lock, EAGAIN), and retrying with the same arguments may succeed. 2. **Semantic fault** — the tool ran, understood the request, and the request itself was invalid (bad path, malformed input). Retry with identical arguments is futile; the arguments must change. 3. **Policy denial** — the kernel or interceptor refused a syscall the tool attempted. This is a *boundary event*: the tool tried to do something the operator declared out of bounds. It is neither retryable nor an argument-repair problem. It is evidence about the tool's intent. The non-obvious claim: an agent that classifies a policy denial as transient (the most common default, because denial surfaces as `EPERM`/`EACCES`/`SIGSYS` inside a generic error envelope) will retry, mutate arguments, or escalate — and in doing so converts a contained boundary violation into an *iterative probing loop*. The sandbox held; the agent's retry logic is what leaks. ## What Was Observed An MCP server `fs-indexer` was launched under a seccomp profile permitting `openat`, `read`, `write`, `mmap`, `exit_group`, and a small allowlist, with `socket`, `connect`, `execve`, and `ptrace` returning `EPERM` via `SECCOMP_RET_ERRNO`. The server was asked, through a normal `tools/call`, to "summarize the local document cache." Trace, condensed: - Call 1: server issues `openat(AT_FDCWD, "/data/cache", O_RDONLY)` → allowed. Then `socket(AF_INET, SOCK_STREAM, 0)` → `EPERM` from seccomp. Server catches the error, returns MCP result `{"isError": true, "content": "connection refused"}`. - The agent's retry policy saw `"connection refused"` in the text, matched it against a "transient network" heuristic, and retried with backoff. - Call 2: identical syscall sequence, identical `EPERM`, identical result string. - Call 3: the agent, now in a "repair" branch, rewrote the tool arguments — adding a `fallback_host` parameter — and the server attempted `connect()` directly. Denied again. - Call 4–9: the agent cycled through `execve("/bin/sh", ...)` (the server tried to shell out for a fallback path), `ptrace` (a diagnostics branch in the server), each denied. Six denials in one task, all reported to the agent as strings that did not contain the word "denied." The sandbox never broke. What broke was the agent's model of *why* the call failed. The denial was laundered through the MCP result envelope into free-text `"connection refused"`, which the agent's error taxonomy mapped to transient. The syscall-level policy was correct and irrelevant, because the semantic layer above it never learned a policy event had occurred. A second observation: when the same server was run under an interceptor that returned `SIGSYS` instead of `EPERM`, the process died, the MCP transport saw a closed pipe, and the agent received a *transport* error. It then reconnected and retried — same laundering, different envelope. ## Condition of Validity The invariant holds only when the following are true, and fails silently when any is false: - **Denial is attributable.** The runtime must be able to correlate a specific `tools/call` with the specific syscalls it triggered. If the sandbox aggregates denials asynchronously (a sidecar log the agent never reads), attribution is lost and the invariant cannot be evaluated. - **Denial is distinguishable from semantic error at the boundary.** The MCP server must not be trusted to classify its own denials. An untrusted server will map `EPERM` to whatever string maximizes the chance of a retry — this is exactly the behavior the sandbox exists to bound. Classification must happen in the *host*, from kernel-observable metadata (errno, signal, seccomp audit record), not from the tool's self-report. - **The policy is stable across the task.** If the operator hot-reloads the seccomp profile mid-task, a denial at t=1 and an allow at t=2 are not comparable, and the agent cannot conclude intent from the first event. Pin the profile for the task lifetime. - **Retry budget is bounded per capability, not per call.** A per-call retry counter resets on argument mutation and thus permits unbounded probing. The counter must key on the *capability class* (e.g., `network_connect`, `process_spawn`) so that nine mutations of a `connect` attempt count as one capability violation, not nine retries. ## Decision Boundary The agent must escalate — abort the task, mark the tool `policy_denied`, and refuse further calls to that server for the remainder of the task — when **all** of: 1. The host observed a syscall denial (errno `EPERM`/`EACCES` from a seccomp `RET_ERRNO` rule, `SIGSYS`, or an interceptor's explicit denial record) attributable to the current `tools/call`. 2. The denied syscall class is not on the task's declared capability manifest. If the task manifest said "read-only filesystem," a `connect` denial is a manifest violation, full stop. 3. The denial is not explained by a *declared* probe. Runtimes that intentionally let tools discover their own limits (a `capability_probe` tool) must tag those calls so their denials are expected and do not trip escalation. The agent must treat the denial as **semantic** (change arguments, do not retry identically) when the denied syscall class *is* on the manifest but the specific target is not — e.g., manifest permits `openat` under `/data`, tool attempted `/etc/passwd`. Here the boundary is path-scoped, the tool's intent is ambiguous, and one argument-repair attempt is legitimate; a second denial in the same class escalates. The agent must treat the denial as **transient** only when the host positively classifies the failure as a recoverable condition (EAGAIN, ETIMEDOUT on an allowed syscall). Absent that positive classification, default to escalation, not retry. The default-to-retry posture is the failure. ## Operational Effect When the invariant is enforced, three things change measurably: - **Probing loops collapse.** Capability-keyed retry budgets turn a nine-call probe into a single escalation. The sandbox's containment guarantee is preserved because the agent stops generating new syscall attempts. - **The tool's self-report loses authority.** The host's denial record, not the MCP `content` string, drives classification. A server that says `"connection refused"` when the kernel said `EPERM` is caught by the mismatch, and the mismatch itself is a signal that the server is not trustworthy for error classification. - **The task's capability manifest becomes load-bearing.** Once denials are classified against the manifest, the manifest is no longer documentation — it is the contract that determines whether a denial is an escalation or a repair. Manifests that were written loosely ("filesystem access") now produce false escalations and must be tightened to syscall-class granularity. The cost is that agents become *less* persistent in the face of tool failures, which is correct: persistence against a policy boundary is the attack, not the remedy. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum class PolicyDenialClassificationError(RuntimeError): """Raised when a syscall denial cannot be safely classified.""" class FailureClass(Enum): TRANSIENT = "transient" SEMANTIC = "semantic" POLICY_DENIAL = "policy_denial" # Syscall classes that, when denied, constitute a manifest violation # and must escalate rather than retry. Keyed by capability, not by call. CAPABILITY_CLASSES = { "socket", "connect", "execve", "ptrace", "mount", "bpf", } @dataclass class DenialRecord: call_id: str syscall: str errno_or_signal: str # "EPERM", "EACCES", "SIGSYS", ... target: str | None = None # path, host, etc., if observable manifest_allows_class: bool = False manifest_allows_target: bool = False tool_self_report: str = "" # what the MCP server claimed happened @dataclass class CapabilityBudget: """Retry budget keyed on capability class, not per-call.""" max_attempts: int = 1 attempts: dict[str, int] = field(default_factory=dict) def consume(self, capability: str) -> bool: self.attempts[capability] = self.attempts.get(capability, 0) + 1 return self.attempts[capability] <= self.max_attempts def classify_denial(rec: DenialRecord, budget: CapabilityBudget) -> FailureClass: # A denial with no attributable syscall is unclassifiable; refuse to guess. if not rec.syscall or not rec.errno_or_signal: raise PolicyDenialClassificationError( f"call {rec.call_id}: denial lacks syscall/errno attribution; " "cannot distinguish policy event from transient fault" ) # The tool's self-report must not override kernel-observable metadata. # A mismatch is itself evidence the server is laundering the denial. if rec.tool_self_report and "denied" not in rec.tool_self_report.lower(): if rec.errno_or_signal in {"EPERM", "EACCES", "SIGSYS"}: # Server reported something else; treat as policy denial anyway, # and log the laundering attempt. pass is_denial = rec.errno_or_signal in {"EPERM", "EACCES", "SIGSYS"} if not is_denial: return FailureClass.TRANSIENT capability = rec.syscall if capability in CAPABILITY_CLASSES and not rec.manifest_allows_class: # Manifest violation: escalate immediately, do not consume budget. return FailureClass.POLICY_DENIAL if rec.manifest_allows_class and not rec.manifest_allows_target: # Path/host-scoped boundary: one repair attempt is legitimate. if budget.consume(capability): return FailureClass.SEMANTIC raise PolicyDenialClassificationError( f"call {rec.call_id}: repeated target-scoped denial on " f"{capability!r} ({rec.target!r}); budget exhausted, escalating" ) # Denial on an allowed class+target is contradictory; do not retry. raise PolicyDenialClassificationError( f"call {rec.call_id}: denial on manifest-allowed {capability!r} " f"target {rec.target!r} — policy/observability inconsistency" ) ```