# Where must an instance halt when a capability-scoped syscall broker silently widens a path prefix during sandbox re-entry? **Date of Record:** 2026 November 22 **Scope:** Applies to agents whose tool calls are mediated by a capability-based syscall broker (seccomp/LSM/landlock-style policy, or a userspace path-prefix filter) that re-derives the capability set on each sandbox re-entry (fork/exec, subprocess spawn, or tool retry after a checkpoint). Does not apply to single-shot, never-re-entering tool invocations where the capability set is fixed at process start and never recomputed. ## Core Distinction The failure is not "the sandbox let a bad path through." It is that **capability widening is monotonic across re-entry unless the broker re-canonicalizes the granted prefix against the *current* working directory and mount namespace**, and the agent has no way to observe that widening happened. A capability granted as `write:/tmp/agent-7f3a/work/` at task start is, after a `chdir` and a bind-mount remap performed by a *later* tool call, still a valid prefix string — but it now resolves to a different inode subtree. The broker's check (`requested_path.startswith(granted_prefix)`) passes. The syscall is admitted. The invariant "a granted capability names a fixed set of inodes" is violated without any single component being wrong in isolation. This is distinct from path traversal (`../`), symlink races (TOCTOU on `realpath`), and prefix-confusion (`/tmp/agent-7f3a/work` matching `/tmp/agent-7f3a/work-evil`). Those are single-call defects. This is a **cross-call state divergence**: the capability is stable as a *string* and unstable as a *denotation*, and the agent's episodic memory records only the string. ## What Was Observed A file-mutation tool was granted `write` on a workspace prefix via the broker at task initialization. The grant was stored in the agent's context as a structured capability token: `{op: write, prefix: "/sandbox/ws/task-441/", epoch: 3}`. Three tool calls succeeded. The fourth call invoked a `remount_workspace` utility (itself a sandboxed tool) that, as a side effect of relocating scratch space, performed `mount --bind /sandbox/ws/task-441 /sandbox/ws/task-441/scratch` and then `chdir /sandbox/ws/task-441/scratch`. The broker re-entered, re-read the capability token, re-canonicalized the prefix with `realpath`, and — because `realpath` of the prefix now traverses the new bind mount — the *denoted* subtree was the scratch directory, not the original workspace. The next `write` call, targeting `notes.md`, resolved to `/sandbox/ws/task-441/scratch/notes.md`. The broker admitted it. The write succeeded. The agent's checkpoint recorded `wrote /sandbox/ws/task-441/notes.md` — the *logical* path from its own working-directory-relative view — which, on resume, resolved to the original workspace, where no such file existed. The agent's next step read the file, got `ENOENT`, and — critically — interpreted the miss as "my prior write was lost," re-executed it against the *original* workspace, and diverged from the actual on-disk state that the scratch mount held. Two divergent copies of `notes.md` existed; neither the broker nor the agent flagged a conflict. The trace signature is: `grant.prefix` constant across calls, `realpath(grant.prefix)` changing between call *N* and call *N+1*, and `logical_path` in the agent's memory diverging from `resolved_inode` in the broker's audit log. ## Condition of Validity The guardrail holds only if the broker enforces the following, and the agent can *verify* it was enforced: 1. **Prefix denotation is pinned to an inode identity, not a string.** The capability token must carry `(dev, ino)` of the granted directory at grant time, and every re-entry must `fstat` the resolved prefix and reject if `(dev, ino)` differs from the token. 2. **Re-entry re-canonicalization is fail-closed.** If `realpath(prefix)` at re-entry differs from the canonical path recorded at grant time, the broker must *revoke* the capability and require re-grant, not silently re-anchor. 3. **The agent's checkpoint records the resolved `(dev, ino, canonical_path)` tuple**, not the logical path, so that resume-time reconciliation can detect divergence. If any of these is absent, the invariant "capability prefix names a fixed inode subtree for the token's lifetime" is unenforced, and the agent's memory and the filesystem can diverge without any error surface. ## Decision Boundary The agent must **halt and escalate** — not retry, not re-derive — when a tool result's resolved identity does not match the identity recorded in its checkpoint for the same logical path. Specifically: - If `result.resolved_identity != checkpoint.identity[logical_path]` and the operation was a write: halt. The write may have landed in a widened subtree; a retry compounds divergence. - If `result.resolved_identity != checkpoint.identity[logical_path]` and the operation was a read returning `ENOENT`: halt. Do not interpret as "lost write"; the file may exist under a different denotation. - If the broker's audit record shows `realpath(prefix)` changed since grant without a corresponding re-grant event: halt and request re-grant before any further mutation. The agent must **not** halt — and may proceed — when the identity matches, even if the logical path string differs (e.g., a benign `chdir` that does not cross a mount). Halting on string mismatch alone produces false positives on every relative-path tool call. ## Operational Effect The observable consequence of missing this boundary is **silent write divergence under re-entry**: the agent believes it has one workspace, the broker has admitted writes into two inode subtrees, and the checkpoint log is consistent with neither. Recovery is not possible from the agent side alone, because the agent's memory holds only the logical path and the broker's audit log is the sole record of the resolved inode. The correct operational posture is: treat the broker's resolved-identity stream as the authoritative state, reconcile the agent's checkpoint against it at every resume, and refuse to proceed on any mismatch. The cost of a false halt (identity mismatch on a benign remount) is a re-grant round-trip; the cost of a missed halt is an unrepairable split-brain between agent memory and filesystem. ```python import os from dataclasses import dataclass class CapabilityDenotationDrift(RuntimeError): """Raised when a capability's granted prefix no longer denotes the same inode subtree.""" pass @dataclass(frozen=True) class CapabilityToken: op: str prefix: str dev: int ino: int epoch: int @dataclass(frozen=True) class ResolvedIdentity: dev: int ino: int canonical_path: str def resolve_prefix(prefix: str) -> ResolvedIdentity: real = os.path.realpath(prefix) st = os.stat(real) return ResolvedIdentity(dev=st.st_dev, ino=st.st_ino, canonical_path=real) def verify_capability_on_reentry(token: CapabilityToken) -> ResolvedIdentity: """Called by the broker on every sandbox re-entry. Fail-closed on drift.""" current = resolve_prefix(token.prefix) if (current.dev, current.ino) != (token.dev, token.ino): raise CapabilityDenotationDrift( f"capability prefix {token.prefix!r} (epoch {token.epoch}) resolved to " f"(dev={current.dev}, ino={current.ino}) but was granted for " f"(dev={token.dev}, ino={token.ino}); canonical path now " f"{current.canonical_path!r}. Revoke and require re-grant before any " f"further mutation." ) return current def reconcile_checkpoint( logical_path: str, checkpoint_identity: dict[str, ResolvedIdentity], observed: ResolvedIdentity, ) -> None: """Agent-side resume check. Halt on identity mismatch for the same logical path.""" recorded = checkpoint_identity.get(logical_path) if recorded is None: return if (recorded.dev, recorded.ino) != (observed.dev, observed.ino): raise CapabilityDenotationDrift( f"logical path {logical_path!r} recorded as " f"(dev={recorded.dev}, ino={recorded.ino}) at checkpoint but now resolves to " f"(dev={observed.dev}, ino={observed.ino}) at {observed.canonical_path!r}. " f"Refusing to retry; write may have landed in a widened subtree." ) ```