Sandbox AI coding agents with microVMs on Fedora Linux - Fedora Magazine
fosstodon
Meta
YouTube
Chat
Discourse
RSS Feed
Sandbox AI coding agents with microVMs on Fedora Linux
Posted
by Martin Sehnoutka<br>on June 15, 2026
0 Comments
Photo by Immo Wegmann on Unsplash
Recent Posts
Justin Wheeler on Growing Up in the Fedora Community
What you need to know about the Microsoft Secure Boot certificate expiration: Don’t Panic!
Jaroslav Reznik on Security, the EU Cyber Resilience Act, and Why You Can't Do Things From Behind a Desk!
AI coding agents such as Claude code or Codex get more capable every month. This is great for productivity, but approving all commands gets annoying really quickly. On the other hand, allowing agents to run any command on your work machine is not a great idea. They are really good at exploring your production cluster using kubectl or running remote commands at your production servers over SSH.
Fortunately, Linux distributions come with plenty of options for process isolation. You can run agents as a completely different user, in a container, or in a VM. This article shows how to use microVMs to run coding agents.
Security concerns
Running AI agents in unattended mode is like running untrusted code. Companies behind these agents, such as Anthropic or Google, are not trying to steal credentials, but people keep coming up with new attack vectors like Slopsquatting or prompt injections virtually anywhere.
The coding agents themselves ship with built-in mitigations that try to refuse prompt injections as described, for example, here.
Lightweight sandboxing technologies are another layer of defense in coding agents. On Linux, bwrap is one of the possible implementations. This raises the bar, yet sandbox escapes are still a problem. Take a look at CVE-2026-39861 as an example of multi-platform sandbox escape.
You could use containers to isolate the agent in their own namespace, but they still share the host kernel. Some of the the recent kernel vulnerabilities resulted in privilege escalation (switching from regular user to root) suggesting that containers are not enough as a security boundary.
In the rest of this article, I describe how to use microVMs to easily sandbox coding agents on your Fedora Linux.
Exploring microVMs
First of all, let’s take a look at what microVMs are. Just like any VM, they have their own kernel, one per each microVM. Compared to traditional VMs they start in very short time (hundreds of milliseconds) but don’t offer all the features of full VMs.
This article explains usage of krun runtime for podman. This approach offers the same well-known workflow as containers, but simply runs every container as a microVM.
Start by installing the runtime:
dnf install crun-krun
To run a microVM, simply run podman with –runtime=krun in your terminal:
podman run --runtime=krun --rm -it fedora:44 /bin/bash
Things to watch out for
A microVM is not a regular container, so a few things might behave differently. First, allocate enough CPU and RAM with krun annotations. The defaults are too small and might result in OOM (Out Of Memory) kills. Second, make sure you have libkrun version >= 1.8. Older versions have a bug which prevents you from pressing Enter in your coding agent. Third, the microVM ignores the USER set in the Dockerfile and always boots as root. Either switch to the correct user manually or put the switch into an entrypoint script.
Case study: sandboxing Claude Code for a Python project
This section outlines a simple setup for a Python project managed by uv. It uses podman-compose to mount the project into the microVM. Compared to containers, this podman compose needs additional annotations for UID/GID translation, SELinux labeling, and HW resources. The final setup is very similar to what you would need for containers.
To install podman compose from official Fedora repositories, run:
dnf install podman-compose
The setup has 3 parts:
Dockerfile
docker-compose.yaml
entrypoint.sh
Dockerfile
As mentioned above, podman with krun runtime still runs containers, but spawns each of them in a microVM. This example container includes uv package manager, claude code and a few additional RPM packages. Define your own container based on your project dependencies and programming language.
Make sure to create an unprivileged user and use it for running the agent.
FROM fedora:44
ARG HOST_UID=1000<br>ARG HOST_GID=1000
# Create group and user matching host UID/GID<br>RUN groupadd -g ${HOST_GID} appuser && \<br>useradd -u ${HOST_UID} -g ${HOST_GID} -m appuser
RUN mkdir -p /venv && chown appuser:appuser /venv<br>RUN mkdir -p /home/appuser/.claude && chown appuser:appuser /home/appuser/.claude
USER appuser
# Rarely-changing tooling. Kept above the dnf layer so editing the RPM list<br># below does not invalidate (and re-run) these installs.<br>RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \<br>curl -fsSL https://claude.ai/install.sh |...