Per-Task VM Isolation as the Safe Default for Autonomous Coding Agent Runners
Isolated VMs per task protect agent infrastructure from model-generated code.

A cloud runner for coding agents that use a bring-your-own API key should run each autonomous task in a fresh, isolated VM, with task-scoped credentials and automatic teardown. The execution environment must contain model-generated commands without depending on the agent to respect its own limits.
Why the execution environment became the primary risk surface for coding agents
Interactive copilots left the developer between a suggestion and its execution. A human reviewed and ran the proposed code, with the developer’s machine serving as the execution boundary. Autonomous agents remove much of that intervention. They plan work, execute shell commands, install packages, call external APIs, modify files, and return pull requests with limited per-action confirmation. Security therefore depends on what the machine permits as well as what the model says.
The Rashidi 2026 SoK treats this as a systems-security problem distinct from model alignment. Code generated at runtime cannot be fully predicted or whitelisted in advance, unlike a known application whose execution paths engineers can constrain before deployment. External connectivity supports legitimate work, but the same connectivity opens paths for exfiltration. An execution boundary must account for both needs without assuming that a reasonable-looking command is safe.
What confirmed CVEs and policy failures show about the current state of agent execution security
The Rashidi SoK systematizes papers published between 2023 and 2026 and documents disclosed, patched vulnerabilities affecting production execution systems. One example is CVE-2024-21626, a runc container-escape vulnerability in which a leaked file descriptor allowed access to the host filesystem. The failure crossed an actual execution boundary. It was not merely an agent giving an undesirable answer, and it affected a runtime on which many agent sandboxes are built.
The same study finds that failures in policy enforcement can affect nearly all real denylists under the adversarial conditions it studied. No isolation paper in its corpus re-evaluates its own defense under that setting. The research gap extends beyond malicious instructions. Benign but out-of-scope actions occur at substantial rates under realistic prompting, yet no access-control or capability paper in the corpus addresses them. The study also finds that time-of-check-to-time-of-use races and Model Context Protocol threats are treated separately despite sharing a validate-then-act structure. Together, these findings expose a gap between what defenses assume and what execution systems enforce.
Why containers are not an adequate isolation boundary for agent workloads
Containers leave workloads sharing the host kernel, which makes them an inadequate default boundary for externally supplied or multi-tenant agent work. A container escape can expose more than one command’s immediate effects. Agent sessions are multi-step and stateful. An early step that is compromised or malformed can change what happens later, so the damage can spread through the rest of the session. Keeping applications separate does not close that gap at the kernel boundary.
gVisor provides a legitimate middle ground by intercepting syscalls before they reach the host kernel. That interception also introduces latency, kernel-feature compatibility gaps, and an additional attack surface. It can be appropriate for compatible, compute-heavy internal workloads where full VM overhead is not justified, with suitability for external-facing agents depending on the workload. Ordinary containers still have the strongest case on familiarity, speed, and cost, but that case rests on VMs taking much longer to start. MicroVM-class systems change that comparison.
What microVM isolation actually provides and why it is now operationally viable
Firecracker-class microVMs give each session its own guest kernel, so workloads no longer all sit behind a shared host-kernel boundary. A guest-kernel compromise does not directly expose the host kernel. The hypervisor remains an attack surface. However, that surface is orders of magnitude smaller than the shared-kernel boundary, creating a stronger separation between model-generated execution and the infrastructure running it.
Teams that already use Kubernetes can get the same kernel boundary through Kata Containers. It runs OCI containers inside lightweight VMs through a pluggable VMM layer supporting Firecracker, Cloud Hypervisor, QEMU, or Dragonball. Teams can therefore retain Kubernetes-native orchestration while adopting hardware-level isolation. The architecture need not require abandoning container workflows.
MicroVM startup now has near-container characteristics, making fresh machines practical at agent-task throughput. That removes the central objection to per-task creation. It does not remove the need to operate the lifecycle reliably, because pipelines may create and destroy large numbers of environments per hour. Pool management and teardown become performance variables as well as security controls. Teams still need to engineer throughput, but they no longer need to accept a weaker boundary to avoid traditional VM startup costs.
Why ephemerality — not just isolation — is the other half of the safe default
A well-isolated machine can still become unsafe to reuse. Long-lived sandboxes accumulate state across sessions, allowing contamination and persistence to survive beyond the task that introduced them. Isolation protects the surrounding infrastructure. Ephemerality protects later work from earlier work by creating a fresh environment for each task and destroying it afterward. For multi-tenant platforms executing arbitrary generated code, both properties are required.
This does not require discarding state after every command. A single task may have many steps whose results shape what runs next, so it must keep its working state within that session. The distinction is between continuity within a task and reuse across tasks. A time to live, or TTL, provides the backstop when normal cleanup fails, automatically reaping an abandoned or runaway VM. Without that limit, a stuck session can retain state and consume resources indefinitely, undermining the intended lifecycle.
The operational requirements a per-task VM architecture actually imposes
This architecture needs controls that keep work contained both when the VM boots and as the agent uses tools. Network egress should default to deny, with explicit exceptions for the external calls a task legitimately needs. Open egress leaves exfiltration paths available, while complete lockdown prevents useful work. Resource limits must also be part of the operating model. Otherwise, machine isolation alone does not bound a runaway task’s resource consumption.
Credentials require a separate constraint within that boundary. Agents should never get host credentials or shared service-account tokens inside the VM. Task-scoped credentials should be injected when the session starts and kept out of agent-visible context and model input. Every execution step should also be traceable through what ran, what it produced, and what resources it consumed. Without that record, teams lose the trail they need to debug the work and hold each task to account.
The lifecycle must end as reliably as it begins. Teardown should destroy the whole session and keep its state out of later runs, with TTL enforced if cleanup fails. At scale, incomplete teardown also impairs throughput. To avoid doing the same setup for every task, teams should put standard dependencies and tooling in environments at image build time. Pre-loading addresses cold-start overhead without relying on the reuse of a previously active session.
How credential and identity design inside agent VMs closes the access-control gap
A VM boundary cannot restrict what an overprivileged credential authorizes elsewhere. Even a well-isolated session with a broad shared service account can leave more at risk than a weaker local boundary with tightly scoped access. Credential scope is an isolation property. It determines how far a compromised session can reach beyond its own machine, making identity design part of containment.
The Rashidi SoK finds that every reviewed enforcement mechanism assumes an honest policy author, leaving policy-authoring error unaddressed in the corpus. Conservative credential design reduces dependence on that assumption. Task-scoped credentials issued at session start and revoked at teardown limit access to the task’s lifetime, while acting as the authorized user makes each action attributable to a specific principal. Shared bot identities give broad access that lasts beyond the task and make it harder to tell who was responsible for each task.
The study documents a Claude Code project-load flaw that leaked API keys before a user accepted repository trust. That sequence exposes the weakness of relying on a later approval step to protect secrets already available earlier in execution. Secrets must not appear in agent-visible context or model input. Hardware isolation cannot make up for giving secrets to a process whose behavior is uncertain.
What per-task VM isolation requires from the harnesses that run inside it
Harnesses bring different assumptions about persistence and shell safety into an ephemeral VM. Claude Code uses syntax-tree parsing, a safety model, and an OS-level sandbox, but the Rashidi SoK also documents a code-injection flaw in its startup trust-dialog flow. Built-in safeguards do not eliminate the need for containment. The environment must remain a separate boundary rather than inheriting its security posture from the harness’s internal checks.
Opencode presents a different operating requirement. It is MIT-licensed and uses tree-sitter parsing, but it has no built-in sandbox, leaving isolation entirely to its execution environment. Per-task VM isolation is therefore mandatory for deployments handling untrusted or external-facing tasks. Syntax parsing is not a substitute for containment.
For teams dispatching different harnesses by task type, the lesson is to establish a common VM baseline at the runner level. A fresh, pre-configured VM should support the harness suited to the job without changing the underlying security posture. This separates harness choice from infrastructure protection. It also lets teams run harness-agnostic systems without having to trust that every agent has the same internal controls.
How analytics and attribution on per-task VMs turn security infrastructure into operational visibility
Each per-task VM creates a natural measurement boundary because its compute record and execution logs belong to a single session. Persistent shared environments instead commingle concurrent work. With task boundaries explicit, teams can attribute compute minutes to the source, harness, model, and credential responsible for them.
Putting per-task VM isolation into production for engineering teams running agents at scale
Teams should stage adoption by task risk, leaving the most ambitious work for later. Agents can begin by adding tests and fixing small bugs, where the scope is bounded and results are easy to validate. Low-risk refactors can follow. Next come dependency updates and documentation sync, followed by cross-module feature work. This order gives teams time to learn how to run the system while failures still cost relatively little.
Integration should preserve the places where engineers already assign and review work, including Slack, Linear, GitHub, and GitLab. The delegation trigger and pull-request review need not expose the machine lifecycle to the engineer. Isolation should operate beneath those workflows. Access to a recording of the agent’s execution then lets reviewers inspect its trajectory as well as its proposed changes, which is especially useful while establishing trust during early delegation.
Teams should judge that rollout through cycle time from issue to merged PR, change-failure rate, senior-engineer review load, and how much of the test suite the agent maintains. Lines of AI code are a poor substitute. Per-session attribution lets teams tie those outcomes to the agent’s work.
Before taking on higher-risk tasks, teams should check that teardown is fully automated and TTL-enforced. Credentials must be task-scoped and kept out of model context, and audit logs must record per-session attribution for the harness and model. These are the gates for broader delegation.


