Proving file integrity for an xv6 sandbox
Recent events have shown why reliable sandboxes matter. We built a virtual-machine sandbox on xv6, a small teaching operating system, and proved that its guest cannot change the files already on the host’s disk. The guest can be any program, including deliberately malicious code. The proof covers the compiled machine code using formal semantics for an eight-core RISC-V machine, including crashes and sudden power loss.
The guarantee
Theorem. For all guest programs, if you power on the machine and start
vmm,1 1 Start from the supplied disk image. At the$prompt, runvmm --no-output-runand type nothing else. The guest receives no input and its output is discarded. every file on disk stays the same, regardless of crashes.2 2 The host kernel creates an empty canary file under/sys/vmm/when setting up the VM, andvmmchecks it for unexpected changes. The theorem allows this file to be created but requires it to stay empty. The original files must remain unchanged.
The theorem statements and proofs are public, so anyone can inspect the exact guarantee.
Allowing crashes makes the guarantee stronger. A malicious program could change a file, then restore it before finishing. Checking only the final state would miss that change. A power cut between those operations would expose it. The proof must account for the files left on disk whenever execution stops.
How the proof works
The host runs xv6 and controls the disk. We added a hypervisor inside the xv6
kernel to enforce the virtual-machine boundary, and a small host program
called vmm to load and start the guest inside it.
We started from xv6iris,3 3 Extending concurrent separation logic to the hardware level to verify the xv6 OS kernel on RISC-V with AI agents, arXiv, 2026, M. Frans Kaashoek and Nickolai Zeldovich. which verifies the compiled xv6 kernel against the official RISC-V processor specification and accounts for multiple cores. We extended its proof to cover processor virtualization, which xv6iris had left disabled, and to establish what an untrusted guest can do.
- Compiled machine code. It checks the bytes the processor executes, so the guarantee does not depend on trusting the compiler.
- Concurrent execution. It covers every order in which eight cores’ steps can interleave as they run alongside each other and take interrupts, under a memory-ordering model slightly stricter than RISC-V’s default.
- Guest-controlled page tables. The guest controls its own address mappings. The hypervisor adds a second layer underneath, and the processor caches both. The proof must account for these translations even when the guest fills its tables with malicious entries.
There are too many interleavings to test them all. Two cores taking four steps each can interleave in 70 ways. For three cores it’s 34,650, and for eight about 2.4 × 10²⁴.
| Cores ↓ | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 2 | 2 | 6 | 20 | 70 | 252 | 924 |
| 3 | 6 | 90 | 1,680 | 34,650 | 756,756 | 1.7 × 107 |
| 4 | 24 | 2,520 | 369,600 | 6.3 × 107 | 1.2 × 1010 | 2.3 × 1012 |
| 5 | 120 | 113,400 | 1.7 × 108 | 3.1 × 1011 | 6.2 × 1014 | 1.4 × 1018 |
| 6 | 720 | 7.5 × 106 | 1.4 × 1011 | 3.2 × 1015 | 8.9 × 1019 | 2.7 × 1024 |
| 7 | 5,040 | 6.8 × 108 | 1.8 × 1014 | 6.6 × 1019 | 2.9 × 1025 | 1.4 × 1031 |
| 8 | 40,320 | 8.2 × 1010 | 3.7 × 1017 | 2.4 × 1024 | 1.9 × 1031 | 1.7 × 1038 |
| Cores ↓ | 1 | 2 | 3 |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 2 | 2 | 6 | 20 |
| 3 | 6 | 90 | 1,680 |
| 4 | 24 | 2,520 | 369,600 |
| 5 | 120 | 113,400 | 1.7 × 108 |
| 6 | 720 | 7.5 × 106 | 1.4 × 1011 |
| 7 | 5,040 | 6.8 × 108 | 1.8 × 1014 |
| 8 | 40,320 | 8.2 × 1010 | 3.7 × 1017 |
| Cores ↓ | 4 | 5 | 6 |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 2 | 70 | 252 | 924 |
| 3 | 34,650 | 756,756 | 1.7 × 107 |
| 4 | 6.3 × 107 | 1.2 × 1010 | 2.3 × 1012 |
| 5 | 3.1 × 1011 | 6.2 × 1014 | 1.4 × 1018 |
| 6 | 3.2 × 1015 | 8.9 × 1019 | 2.7 × 1024 |
| 7 | 6.6 × 1019 | 2.9 × 1025 | 1.4 × 1031 |
| 8 | 2.4 × 1024 | 1.9 × 1031 | 1.7 × 1038 |
To reason about concurrent execution, xv6iris uses bookkeeping that exists only in the proof, called ghost state. The proof assigns an exclusive permission to each disk block and requires every write to account for it. The guest has none of these disk permissions. We must also show that the host’s handling of the guest preserves the original files.
This bookkeeping lets the proof reason about one core at a time while still covering their possible interactions. It is part of concurrent separation logic, a technique our hypervisor proof reuses from xv6iris.
Related work
seL4 proved a whole microkernel correct, and for some versions carried the proof down to the compiled binary. Its verified versions run on a single core, its processor model is hand-written, and its proof does not cover the kernel’s handling of caches or the TLB, the processor’s cache of address translations.
SeKVM proved that a multiprocessor version of Linux’s KVM hypervisor on Arm protects the confidentiality and integrity of its guests’ data. Its proofs cover the C code and the assembly separately, against a hand-written machine model, and the two are not linked.
Our theorem does not protect what a guest can learn. In that respect, it proves less than seL4 and SeKVM.
Islaris is closest to us in method. It reasons about machine code against the official Sail processor specifications.
CertiKOS is the closest in overall scope. It verifies a concurrent kernel for multicore x86 that can also run Linux guests. CertiKOS proves its C code and relies on a verified compiler to carry that proof down to machine code, and its x86 machine model, which its authors wrote, assumes the strictest memory ordering. We prove the machine code itself, against the official RISC-V specification, including the processor’s own page-table walks and Translation Look-Aside Buffer (TLB), under a weaker memory ordering. And CertiKOS proves that its kernel matches its specification, while our theorem is about what a (potentially hostile) guest can do.
What you have to trust
Rocq checks the proof, but the guarantee still depends on the definitions of the machine and theorem, the checker and its assumptions, and running the exact binaries the proof describes.
The semantics describe how the processor and devices behave. Our proof uses a RISC-V configuration that no available chip matches exactly. Applying the guarantee to real hardware requires showing that the hardware follows these semantics. Tests so far run on QEMU.
The trusted definitions include about 5k lines describing the machine and stating the theorem, including about 1.7k lines of hand-written semantics for the console, interrupt controller and disk. The processor specification adds about 80k lines of Rocq generated from the official Sail description of RISC-V, as configured for this proof. Sail’s floating-point specification is also trusted and is not completely modeled in Sail.
The memory-ordering model is slightly stricter than RISC-V’s default. QEMU, which we use for testing, also differs from the processor semantics used in the proof. We also found a bug in QEMU.
The checker is Rocq, including its built-in types PrimString and PrimInt.
The proof assumes function extensionality, which says that functions are
equal if they agree on every input.
Before a run, our build system checks the hashes of the kernel and filesystem. If either differs from the files the proof describes, it refuses to start unless you override it. A build from source on a fresh machine produces the same bytes.
Scope and next steps
This is a proof of file integrity for a specific sandbox configuration. It does not establish confidentiality or guarantee that the guest finishes. xv6 has no network or user accounts, and a 2 MB file system. The guest cannot yet interact with an outside user or return output in the proved mode.
Next, we want to protect secrets as well as files, prove that the system keeps making progress, support interaction with the guest, and extend the guarantee to real hardware.
This establishes the approach on a small system. Extending it to production sandboxes remains the larger challenge.
If you are interested in preventing agent escapes, get in touch!
@misc{theorem2026provingagentsandboxes,
title = {Proving file integrity for an xv6 sandbox},
author = {Aditya Tewari and Harshikaa Agrawal and Sami Jawhar and Luke Champine and Cheru Berhanu and Jason Gross and Nickolai Zeldovich},
year = {2026},
month = {november},
howpublished = {Theorem Blog},
url = {https://theorem.dev/blog/proving-agent-sandboxes/}
}