AI Tools Weekly Sage logoAI Tools WeeklySage
microvmskrun-runtimefedora-linuxpodman-workflowsandbox-escapes

What are MicroVMs for AI Coding Agents?

In the rapidly evolving landscape of local development, securing autonomous software is no longer optional; it is a fundamental requirement for system...

13 min readAI Tools Weekly
Disclosure: This article contains affiliate links. We earn a commission if you purchase through our links, at no extra cost to you.

Sandbox AI Coding Agents with MicroVMs on Fedora: Secure Setup Guide 2026

In the rapidly evolving landscape of local development, securing autonomous software is no longer optional; it is a fundamental requirement for system stability. As AI coding agents such as Claude Code or Codex become more capable every month, the risk of allowing them to run any command on a work machine without oversight increases significantly. Running these agents in unattended mode is comparable to running untrusted code on your host system. While companies behind agents like Anthropic or Google are not trying to steal credentials, new attack vectors such as prompt injections and slopsquatting exist. Lightweight sandboxing technologies like bwrap offer one layer of defense, but sandbox escapes remain a persistent problem. Containers isolate agents in their own namespace but share the host kernel, making them insufficient against recent kernel vulnerabilities that allow privilege escalation, such as CVE-2026-39861. This guide explores how to implement sandbox AI coding agents Fedora users need for robust isolation using microVMs. By leveraging the krun runtime on Fedora Linux, developers can switch their workflow from standard containers to a more secure microVM environment, effectively trading some VM functionality for a separate kernel boundary and faster startup times.

What are MicroVMs for AI Coding Agents?

MicroVMs represent a distinct evolution in process isolation, designed specifically to address the limitations of traditional containers when dealing with semi-trusted or untrusted workloads. Unlike standard containers which share the host kernel, microVMs boot with their own separate kernel. This architectural difference is critical for AI security because it avoids the kernel-sharing exposure present with containers. When an AI agent attempts a sandbox escape, the damage is contained within the microVM's isolated kernel instance rather than compromising the host system's kernel directly.

The primary advantage of this approach is the creation of a separate kernel boundary. While microVMs do not offer all the features of full VMs, they provide a significant increase in the attack surface barrier relative to container-only isolation. For AI coding agents, this means that even if a prompt injection leads to malicious code execution, the agent is confined to its own virtualized environment. The Fedora ecosystem supports this technology through the krun runtime, which integrates seamlessly with the podman workflow. This allows practitioners to maintain the familiar podman commands and Dockerfile structures while upgrading the underlying isolation mechanism to a microVM.

Startup performance is another key factor. MicroVMs offer startup times in the hundreds of milliseconds, which is fast enough for iterative development but slow enough to justify the overhead of a separate kernel. This balance makes them ideal for scenarios where you need to spin up an isolated environment for a coding session and tear it down immediately after, minimizing the window of exposure. The technology effectively converts the trade-off between developer convenience and host safety into concrete steps for Fedora users. By utilizing the krun runtime, you can run AI coding agents Fedora users rely on without sacrificing the speed required for modern development workflows.

Why MicroVMs Matter for Agent Security

The necessity for microVMs in the context of AI agents is driven by the changing nature of autonomous software threats. AI coding agents are good at exploring production clusters using kubectl or running remote commands over SSH. If an agent is compromised, it can cause significant disruption. Practitioners face a practical trade-off between developer convenience and host safety when running autonomous agents locally. The risk is not just about the AI trying to steal data; it is about the AI executing arbitrary commands that could alter system configurations or install malware.

Running AI coding agents in unattended mode is comparable to running untrusted code. Even if the specific attack vector is a sandbox escape, the consequences are severe. Traditional containers provide isolation at the process level, but they share the host kernel. If a vulnerability like CVE-2026-39861 is exploited, it can lead to privilege escalation on the host. MicroVMs mitigate this by providing a separate kernel boundary. This means that a vulnerability in the guest kernel does not necessarily translate to a vulnerability in the host kernel.

The security model shifts from relying solely on user permissions to relying on architectural isolation. Sandboxing untrusted or semi-trusted workloads commonly layers multiple defenses: process-level privileges, containers, and lightweight VMs. While lightweight sandboxing technologies like bwrap are useful, they are often just one layer of defense. MicroVMs add a hardware-assisted layer of isolation that is harder to bypass. This is particularly important given that microVMs ignore the USER set in the Dockerfile and always boot as root, requiring a manual switch or entrypoint script to ensure the agent runs with the correct privileges. This forces developers to be explicit about permission handling, reducing the risk of accidental privilege escalation.

Furthermore, the security implications extend to how agents are managed. If a coding agent is left running, it poses a constant threat. MicroVMs allow for the creation of disposable environments. You can start a fresh microVM for a specific task and destroy it immediately after, ensuring that no long-lived processes remain on the host. This ephemeral nature is a significant security benefit, as it limits the persistence of any potential compromise. The ability to monitor guest-kernel patching and the microVM runtime's resource defaults further enhances this security posture.

How to Set Up the krun Runtime on Fedora

Setting up the environment for sandbox AI coding agents Fedora users require is straightforward but requires attention to specific package dependencies. The core of this setup is the installation of the krun runtime. On Fedora Linux, this is achieved using the dnf package manager. The specific installation command to add the krun runtime is:

dnf install crun-krun

Once the runtime is installed, you must ensure that the podman daemon is configured to recognize and use krun. By default, podman may use the standard container runtime. To switch to microVMs, you need to update your podman configuration to point to the krun runtime. This involves editing the podman configuration file, typically located at /etc/containers/storage.conf or /etc/containers/machine.conf, to specify krun as the preferred runtime for specific contexts. However, the primary mechanism is often handled via the --runtime flag in the podman command, though configuring a default is recommended for production-like environments.

It is crucial to verify the version of the libkrun library being used. Older versions of libkrun, specifically those below version 1.8, have known bugs that can prevent users from interacting with their coding agents, such as the inability to press Enter. Therefore, ensuring that your system has libkrun version 1.8 or higher is a mandatory step in the setup process. You can check the installed version using standard package management tools.

Additionally, if you plan to use podman-compose for managing multiple agents or complex setups, you must install that tool as well. The installation command is:

dnf install podman-compose

When configuring podman-compose for microVMs, you must add specific annotations to your docker-compose.yaml file. These annotations are required for UID/GID translation, SELinux labeling, and the allocation of Hardware resources. Without these annotations, the microVM may fail to start correctly or may not have the necessary permissions to access host resources. The setup process effectively allows keeping the familiar podman workflow while switching the runtime to a microVM, minimizing the learning curve for existing developers.

Step-by-Step Example: Running a Secure Agent

To demonstrate the practical application of this technology, we will walk through running a secure agent using the krun runtime. This example uses a container image that includes the uv package manager, Claude Code, and a few additional RPM packages. This image serves as a robust environment for AI coding tasks.

First, ensure your system is updated and the krun runtime is installed as described previously. Next, prepare your environment by creating a directory for your agent configuration. You will need a Dockerfile, a docker-compose.yaml, and an entrypoint.sh script. The Dockerfile defines the base image, which in this case is fedora:44.

The docker-compose.yaml file is where the magic happens. You must specify the runtime as krun. Here is the essential command structure you will use to run the agent:

podman run --runtime=krun --rm -it fedora:44 /bin/bash

This command starts a new microVM instance. The --runtime=krun flag tells podman to use the microVM runtime instead of the default container runtime. The --rm flag ensures that the microVM is automatically destroyed when the session ends, maintaining the ephemeral nature of the setup. The -it flags allocate a pseudo-tty and keep the session interactive, which is essential for an AI coding agent that needs to accept input.

Inside the microVM, you can install the necessary tools. Since the image includes uv, you can use it to manage Python packages and run scripts efficiently. The agent can now explore the environment, but it is confined within the microVM's kernel boundary. If the agent attempts to access host files outside its designated volume mounts, it will be blocked by the kernel isolation.

For more complex setups, you might use podman-compose. In this scenario, you would define your services in the docker-compose.yaml file. Remember to include the required annotations for UID/GID translation and SELinux labeling. For example:

version: '3.8'
services:
  agent:
    image: fedora:44
    runtime: krun
    command: /bin/bash
    

# Additional annotations for resources and labels would go here

This setup allows you to run multiple agents simultaneously in separate microVMs, each with its own isolated kernel and resource allocation. It is important to note that microVMs ignore the USER set in the Dockerfile and always boot as root. You must configure your entrypoint.sh script to switch to the appropriate user or ensure the agent operates correctly as root within the isolated context.

Common Mistakes and Configuration Risks

When implementing sandbox AI coding agents Fedora, several pitfalls can undermine the security benefits of the setup. One of the most common mistakes is ignoring the default resource allocations. The microVM runtime has small default CPU and RAM allocations. These defaults might result in Out Of Memory (OOM) kills if the AI agent tries to perform heavy computations or load large models. Practitioners are advised to monitor guest-kernel patching and the microVM runtime's resource defaults. You must explicitly configure the memory and CPU limits in your podman or podman-compose configuration to prevent OOM issues.

Another significant risk is relying on outdated software. As mentioned, older versions of libkrun (specifically < 1.8) have a bug preventing the user from pressing Enter in their coding agent. This breaks the interactive experience required for most AI coding tasks. Always ensure your libkrun version is 1.8 or higher. Additionally, be aware that microVMs ignore the USER set in the Dockerfile and always boot as root. If you expect the agent to run as a specific non-root user defined in the Dockerfile, you must implement a manual switch or an entrypoint script to handle this. Failure to do so can lead to permission errors or unintended privilege escalation within the guest environment.

Comparing this approach to containers, the podman-compose setup for microVMs needs additional annotations for UID/GID translation, SELinux labeling, and HW resources. Users often forget to add these annotations, leading to startup failures or incorrect resource mapping. Containers share the host kernel, so they do not require these specific annotations for kernel isolation, but they also do not provide the same level of security against kernel exploits. MicroVMs offer a separate kernel boundary, increasing the attack surface barrier relative to container-only isolation. However, this comes at the cost of some VM functionality and slightly higher resource usage.

It is also important to recognize that microVMs don't offer all the features of full VMs. While they provide a separate kernel, they may lack certain advanced features found in full virtualization. This trade-off is acceptable for AI coding agents, but it is a limitation to be aware of. If your agent requires specific hardware passthrough or advanced virtualization features not supported by krun, you may need to reconsider your architecture.

Finally, always remember that sandbox escapes remain a problem. While microVMs significantly reduce the risk compared to containers, they are not immune to all attacks. The specific CVE cited for sandbox escape is CVE-2026-39861, which highlights the need for vigilance. Monitoring guest-kernel patching is essential to stay ahead of emerging threats.

FAQ: Limitations and Troubleshooting

Why should I use microVMs instead of containers for AI agents? Containers isolate agents in their own namespace but share the host kernel, making them insufficient against recent kernel vulnerabilities that allow privilege escalation. MicroVMs offer a separate kernel boundary, increasing the attack surface barrier relative to container-only isolation. This is crucial for agents running in unattended mode.

What happens if I don't configure the resource limits correctly? The microVM runtime has small default CPU and RAM allocations. If these are too small, you might encounter Out Of Memory (OOM) kills when the agent attempts to run heavy tasks. You must explicitly configure memory and CPU limits to avoid this.

Can I run my agent as a non-root user automatically? No. MicroVMs ignore the USER set in the Dockerfile and always boot as root. You will need to implement a manual switch or an entrypoint script to change the user context after the microVM boots.

What is the minimum version of libkrun I need? You need libkrun version 1.8 or higher. Older versions have bugs that prevent the user from pressing Enter in their coding agent, breaking the interactive session.

Frequently Asked Questions

How do I install the krun runtime on Fedora?

To install the krun runtime on Fedora, use the following command: dnf install crun-krun. Ensure your system is up to date before installing.

What is the command to run a secure agent with krun?

The example command provided to run a secure agent is: podman run --runtime=krun --rm -it fedora:44 /bin/bash. This command spins up a new microVM instance with the specified image.

What annotations are required for podman-compose microVM setups?

The podman-compose setup for microVMs needs additional annotations for UID/GID translation, SELinux labeling, and HW resources. These must be included in your docker-compose.yaml file to ensure proper configuration.


Sources


Recommended AI Tools

Sider AI — All-in-one browser AI sidekick that lets users chat, summarize webpages/videos, translate pages, explain text, research faster, and use multiple AI models in one sidebar. Includes Wisebase knowledge...

Related reviews