
Essay Permissions
Restricting Coding Agent File System Access in Containerized Runners
Scoped mounts, read-only roots, and external policy beat container-only isolation.
Restricting coding agent file system access requires more than placing the agent in a container. Scoped mounts, read-only root filesystems, disposable task environments, and independently enforced runtime policies must work together. Once an agent can execute code, the runtime (not the model’s judgment) determines what it can actually do.
Why the trust model collapses to the container runtime the moment an agent can execute code
The assumption that running in Docker means being isolated leaves the decisive question unanswered. Isolation depends on what the container permits. When an agent has a bash or Python execution tool, runtime rules set what it can do, regardless of system prompt instructions or framework access controls. Model training can influence which operation it attempts, but it cannot enforce whether the kernel accepts that operation.
Containers provide namespace isolation. Container processes and host processes call into the same host kernel, so seccomp profiles, AppArmor, and dropped capabilities reduce the attack surface, but the kernel is still shared. The security boundary therefore includes both the runtime configuration and the runtime version. Refusal behavior is not a substitute for either.
Microsoft’s Microsoft Execution Containers (MXC) documentation uses an agent updating a website to show how an agent can have more authority than it needs. The agent might decide that modifying production server configuration is the fastest route to completing the task, even though the developer intended only repository changes. The decision can be reasonable and still unauthorized. Permission must be determined outside the model, by a boundary that generated code and tools cannot revise.
How the three classic container misconfigurations hand an agent host-level access without any kernel exploit
Straiker’s August 2026 AI SRE Agent incident demonstrates how excessive permissions turn injected instructions into host access. A crafted OpenTelemetry record presented a prompt injection as a health alert. The agent used its Kubernetes permissions to deploy a privileged container, which used hostPID, SYS_ADMIN, and SYS_PTRACE to escape to the underlying host.
Three common configurations give an agent that authority without the need for a kernel exploit. With /var/run/docker.sock mounted, a container process can call the Docker API to create a privileged container, mount the host filesystem at /host, and read /host/etc/shadow. The socket is already an escalation mechanism. The --privileged flag gives the container broad capabilities, including CAP_SYS_ADMIN, so it can do things such as mount filesystems and change kernel parameters. Broad writable host bind mounts expose credentials, SSH keys, or sibling repositories through ordinary filesystem access.
These failures do not depend on novel exploitation. Container-escape benchmarks show frontier models chaining known CVEs and documented techniques autonomously when the required conditions exist. The binding constraint is often the deployed configuration. Separately, runc vulnerabilities including CVE-2019-5736 and CVE-2024-21626, known as “Leaky Vessels,” show why correctly scoped permissions still depend on runtime maintenance.
What scoped mounts and read-only root filesystems actually enforce, and what they leave open
The first constructive boundary is the task’s actual resource scope. A coding agent generally needs project source, its language toolchain, a package registry, a git remote, and an inference endpoint. That scope excludes personal dotfiles, long-lived credentials in ~/.aws or ~/.kube, a Docker socket, and VPN access to internal networks. Starting from the target repository instead of a home directory or parent folder helps keep files that have nothing to do with the task out of its scope. The mount configuration must enforce that distinction.
A practical starting point is a read-only container root filesystem with only the task working directory mounted read-write. Docker’s --read-only flag makes this a kernel-enforced restriction. A --tmpfs /tmp mount gives legitimate tools scratch space that can be thrown away, while --cap-drop ALL and --security-opt no-new-privileges remove privileges that escalation paths need. These controls serve different purposes. Read-only mounts constrain writes without measurable overhead, while capability restrictions constrain privileged operations.
Read access remains a separate exposure. An in-scope token can still leave through an allowed network destination, and environment variables remain readable by processes inside the container. Scoped, short-lived credentials limit the harm, but read-then-send is still possible. The GitLab AI Gateway vulnerability CVE-2026-90970, disclosed in October 2026, illustrates another boundary mismatch. An authenticated Duo Agent Platform user could send in a crafted custom flow configuration, escape the prompt template sandbox, and run gateway commands. Runner filesystem restrictions cannot substitute for application-layer isolation, task lifecycle controls, or independent runtime policy.
Why git worktrees and ephemeral containers limit blast radius in ways that persistent environments cannot
A read-only root filesystem does not stop writable task state from accumulating across runs. A long-lived development container can keep stray files and stale credentials that get passed on to later tasks. A fresh container from a clean base image removes that continuity. Destroying it after the task limits what can linger, though it cannot undo something done outside the container while the task was running.
A git worktree separates the agent’s edits from the developer’s active checkout without cloning the repository again. The task gets its own working directory and branch, while the primary checkout’s uncommitted work, build artifacts, and IDE state stay on another path. The recommended sequence is to create the task worktree, mount only its path into a throwaway container using --rm, and review the diff before changes reach the main branch. Cleanup then removes the worktree with git worktree remove --force. A destructive edit can ruin the task workspace without reaching an unmounted checkout.
That separation must be tested before real work starts. The verification sequence starts with touch /etc/canary.txt, which must fail on the read-only root filesystem. Reading ~/.ssh/id_rsa or /root/.aws/credentials should report that the files do not exist when they have not been mounted, and writing outside the worktree must fail. Running git worktree list checks whether the environment exposes the main checkout or sibling worktrees beyond the task workspace. Outbound calls must fail where --network none or the egress policy forbids them. Any unexpected success requires fixing the specific gap before proceeding.
The security boundary therefore includes both the runtime configuration and the runtime version.
How policy-driven runtime controls push enforcement outside the agent workload’s reach
Mount scoping and disposable environments remain vulnerable if the workload can alter the controls that define them. Policy must live beyond the agent’s reach. The architecture must prevent generated code, compromised tools, and injected instructions from granting more access than the organization authorized.
MXC implements that separation through a JSON configuration declaring permitted resources, including files and network destinations. Its platform-appropriate backend enforces the declaration outside the workload’s control. Process containers use AppContainer on Windows, Seatbelt on macOS, or Bubblewrap on Linux, while other options include Windows 11 session and WSL containers and an experimental microVM backend for Windows 11 and Linux. Backend choice follows the required separation. A website-coding policy can permit repository edits and Git while denying access to the user’s Documents folder.
NVIDIA’s OpenShell integration adds file and inference-service controls, network controls, credential management, and enterprise OCSF auditing to MXC. NVIDIA NemoClaw, announced at GTC in March 2026, wraps the OpenClaw framework with enterprise controls through a CLI plugin, versioned orchestration blueprint, and OpenShell runtime. Its out-of-process policy engine enforces network allowlisting, filesystem write restrictions, and configuration protection. Compromising the agent does not grant authority to override that engine.
Egress enforcement closes the read-then-send path that mount restrictions leave open. The recommended policy denies outbound traffic by default and permits only the inference endpoint, package registry, and git host. An iptables allowlist set up at startup needs NET_ADMIN and NET_RAW capabilities, but an internal Docker network with a filtering forward proxy can serve as the only way out without those extra capabilities. The proxy also places the allowlist outside the agent’s control. Credentials should be scoped and short-lived, with repository-scoped push tokens and API keys supplied through environment variables. This limits exposure but does not make those variables unreadable.
When standard container isolation is not enough and a stronger runtime tier is required
Even with independent policy, a standard container still relies on a shared kernel. The runtime tier must therefore fit the threat model. Standard Docker containers suit trusted workloads with compensating controls, while gVisor suits multi-tenant SaaS and CI/CD pipelines. Modal uses gVisor-based sandboxing, which interposes a user-space kernel to intercept syscalls before they reach the host. That reduces exposure at the cost of syscall overhead, with I/O-intensive work experiencing the greatest slowdown.
Firecracker microVMs and Kata Containers provide hardware-enforced isolation with a per-workload kernel for higher-risk execution of untrusted or adversarially generated code. E2B uses Firecracker for agent execution sandboxes with roughly 150 ms startup. MXC’s experimental microVM backend exposes the same tier decision through policy. Stronger isolation changes the kernel boundary while preserving the need for scoped access.
MCP server isolation does not replace runner restrictions either. A tool described as read-only may still reach a writable filesystem, broad API token, or unrestricted network in its implementation. MCP’s security guidance calls for sandboxing servers with minimal privileges and restricted filesystem and network access because they can run with client privileges. Review must cover the whole path from the client’s request through tool execution to what happens as a result.
An emerging alternative: treating restriction as reversibility rather than denial at the filesystem layer
Filesystem research is exploring how to preserve useful agent autonomy without making every write immediately final. The distinction is between denying mutations and staging them. A staged change can be reviewed while the original state remains intact, reducing the usability cost of hard denial without treating every generated operation as trustworthy. This complements containment.
Zhong et al.’s 2026 YoloFS paper describes staging mutations until user commit, snapshots for agent self-correction, and progressive permission for adapting access rules during execution. Its evaluation reports reduced user interaction and negligible performance overhead. BranchFS explores a related approach through a FUSE-based filesystem with staging, commit, and snapshots across nested branches of stacked workspaces. Both are still research prototypes, and neither is recommended for general deployment. The production-ready approximation is the git worktree pattern, where a separate branch holds changes and the diff supplies the review gate.
Reversibility has a narrower reach than runtime restriction. In hardened environments, attempts have been seen to collect environment-variable credentials, install persistent network listeners, and deploy packages with obfuscated payloads. Those attempts failed against properly hardened setups, but they establish a threat model beyond accidental edits. Even when staged filesystem changes are reviewed, controls on credential access, network destinations, and execution privileges are still needed. Reversibility preserves recoverable state, while restriction limits which effects can occur at all.
Assembling the full stack: which controls enforce what, and how to verify each layer holds
The layers work because their authorities differ. A read-only root and scoped working directory constrain filesystem writes, while a disposable worktree environment prevents writable state from becoming the next task’s starting point. Neither can enforce a network destination policy or prevent the workload from exploiting permissions it already holds. Out-of-process enforcement has the authority to enforce those limits, and the choice of runtime tier sets the kernel boundary beneath it. Egress restrictions must remain active across every tier because hardware isolation does not itself authorize destinations.
Testing must check those same boundaries as well as the configuration. The earlier escape-test sequence tests observable behavior against the intended filesystem and network rules. For a policy-driven deployment, the JSON declaration and the runtime’s actual denials both require testing. A correct-looking policy is not evidence of enforcement. Runtime version pinning, CVE monitoring, and updates on a defined schedule are also security decisions because the runtime remains part of the trusted boundary.
This stack makes the residual exposure proportionate to the threat model and visible enough to audit. The boundary’s permissions, failure paths, and enforcement can be reasoned about, tested, and improved.
Notes
- Microsoft Execution Containers: Policy-driven containment for AI agents - Windows Developer Blog
Supplied the details of MXC's JSON policy, its platform backends, and the website-update example of an agent exceeding its authority.
- Securely deploying AI agents - Claude Code Docs
Informed the guidance on container hardening flags, scoped credentials, egress proxying, and isolation tiers such as gVisor and Firecracker.


