{"slug": "before-i-trust-an-agent-i-try-to-break-its-box", "title": "Before I Trust an Agent, I Try to Break Its Box", "summary": "A developer's adversarial test suite against Koala, a sandbox that runs one Linux VM per AI agent on Macs and Linux hosts, found that an attacker VM running as root connected to 0 of 10 host ports, won 0 of 80,000 to 86,000 race attempts per command port, and could see only its own disks, while a sandboxed escape probe was refused every attempt versus 17 successes without the sandbox. The tests, run on Apple's Virtualization framework and on KVM and Cloud Hypervisor, also surfaced two real bugs — VMs losing network after a manager SIGKILL and one orphaned process, both fixed — and a command that took 6.1 seconds at 67,000 operations of history, now 0.35 seconds. The author argues boundaries fail where the host reaches into the guest, not where the guest reaches out, citing an untested mid-copy symlink swap as the open case.", "body_md": "An AI agent reads web pages, messages, and files, and it may act on instructions hidden in any of them. Sooner or later, something untrusted will run wherever the agent runs.\n\nKoala is my answer to where that should be: [one Linux VM per agent](https://kunalkushwaha.github.io/2026/10/17/give-every-agent-its-own-room/), on a Mac or a Linux machine, with the network policy and the API keys kept on the host. That is a design claim. Claims are cheap. So I attack it from the inside.\n\n## An attacker, a bystander, and witnesses\n\nEvery test runs on real VMs: Apple’s Virtualization framework on Macs, KVM and Cloud Hypervisor on Linux. Each hostile run has three parts.\n\nThe attacker is a VM running as root: an agent fully taken over. The bystander is a healthy VM beside it, answering a check every half second. If the attack breaks the neighbor, the test fails, even if nothing escaped. The witnesses live on the host: listeners that record every packet, file hashes taken before and after, and fake secrets (“canaries”) planted so any leak has a name.\n\nNever believe the attacker. Judge every result by what the host saw.\n\nCode inside the VM can print “access denied” while it gets through. A test that reads the guest’s own report is testing the guest’s honesty, not the boundary.\n\n## What attacking it looks like\n\n| What the attacker tried | What the host saw | \n|---|---|\n| Connect to 10 host ports, including the ones Koala opens for a command’s input and output | 0 of 10 connected | \n| Race Koala to those command ports, 80,000 to 86,000 attempts per port | Won 0 times | \n| Read a victim VM’s disk, or attach its volume | Only its own disks visible; attach refused | \n| Plant a symlink in a shared folder pointing at a host credential, then wait for `koala cp` | Symlink refused, credential untouched. A mid-copy swap was never hit, so that case is untested | \n| Spoofed, fragmented, and IPv6 packets; posing as the router; DNS rebinding | Only the two allowed listeners received anything | \n| 2,000-query DNS flood | 486 answered, the rest refused at once (16 lookups at a time); the helper survived | \n\nThe symlink row is the one I keep thinking about. It does not attack Koala’s code. It attacks Koala’s helpfulness: wait for the host to reach into the guest, and hand it something poisoned. Boundaries rarely fail where the guest reaches out. They fail where the host reaches in.\n\nAround the attacks, more than 40 fuzz targets hit every parser of guest data, and about 1,400 crash checks per platform kill Koala’s processes at chosen moments.\n\n## Break it, and leave it running\n\nDuring the flood, the test also kills Koala’s network helper, and kills its manager outright with SIGKILL. Memory peaked at 325 MiB and open files did not leak. The bystander kept answering: 97% of its checks succeeded. Not 100%. Every check goes through the manager, which the test kills; in the Linux run, every miss fell within two seconds of the kill. It also found two real bugs: after a manager kill, VMs lost their network, and one process was orphaned. Both failed safe, and both are fixed.\n\nThen Koala runs for eight hours with faults injected along the way. On a Mac, all 9,884 operations succeeded. On Linux, one VM stopped taking commands after a restart; the cause, a race in reading its event journal, is now fixed. Long runs also found that one command took 6.1 seconds once Koala had 67,000 operations of history. It now takes 0.35.\n\n## Assume the box already failed\n\nWhat if the attacker gets out anyway, through a hypervisor bug? On Linux, every Koala process that touches a VM runs in its own locked-down sandbox. So an escape probe runs inside each of them, as if the attacker were already there. It tries to read an SSH key and other VMs’ disks, open network connections, start a shell, and freeze Koala’s manager.\n\nEvery attempt was refused, in every sandbox. The same probe, run without the sandbox, got through 17 times. That control is what gives the refusals meaning.\n\nThis is not hypothetical: the recent [Firecracker escape](https://pwn.ai/blog/firecracker-escape) went through the host kernel, then took over a hypervisor running as root with no seccomp ([how Koala avoids the first step](https://kunalkushwaha.github.io/2026/11/09/keep-agent-packets-out-of-host-kernel/)).\n\n## The bug was four bytes\n\nThat probe also caught a real bug: after one refused connection, the sandbox refused every later legitimate one too.\n\nKoala’s Linux sandbox intercepts connections with seccomp, and reads the target address with `process_vm_readv`, called through C’s variadic `syscall()`. Its last argument, a 64-bit flags value, was passed as the `int` 0. Only 4 of its 8 bytes were written; the rest was leftover stack. When those bytes were not zero, the read failed, and the connection was refused. The unit test passed even before the fix, because the leftover bytes depend on the caller. A small C program, run under the real sandbox, now catches it.\n\nIt failed closed, which is the right direction. It was still a bug, and now it has a regression test.\n\n## What I have not tested yet\n\nA VM can always lie about its own commands. It cannot lie about anything else, which is why nothing on the host trusts a guest’s report about itself.\n\nThe detailed attack runs were recorded in October 2026 on a Mac; the same suites run unchanged on Linux, and pass. [Domain grants](https://kunalkushwaha.github.io/homebrew-koala/guide/networking/), new in the latest release, have not been through the root-in-the-guest suite yet. There has been no independent security audit, and no testing beyond macOS 26 and Ubuntu 24.04. Koala is a release candidate; its source goes public with 0.1.0.\n\n## Questions for any sandbox\n\n1. How was the boundary attacked?\n2. Who judged the result: the guest, or the host?\n3. Did the tests run against the real system, or a mock of it?\n4. What happened when something crashed halfway through?\n5. What has the team not tested yet?\n\nAsk them of any vendor that says its agent sandbox is isolated.\n\nRead [how Koala is tested](https://kunalkushwaha.github.io/homebrew-koala/#hostile-guests-crashes-and-fuzzing-on-real-vms), or get the [releases and user guide](https://github.com/kunalkushwaha/homebrew-koala).\n\nI trust the box after it has been attacked, not before.", "url": "https://wpnews.pro/news/before-i-trust-an-agent-i-try-to-break-its-box", "canonical_source": "https://kunalkushwaha.github.io/2026/11/06/before-i-trust-an-agent/", "published_at": "2026-11-06 01:00:00+00:00", "updated_at": "2026-11-28 08:44:32.100808+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools"], "entities": ["Koala", "Apple Virtualization framework", "KVM", "Cloud Hypervisor", "Linux", "Mac"], "also_reported_by": [], "takeaway": "Judge sandbox escapes by host-side witnesses — packet captures, before/after file hashes and planted canary secrets — not by the guest's own output, since a root attacker VM connected to 0 of 10 host ports and won 0 of 80,000-86,000 port races while a sandboxed escape probe was refused every attempt", "recommendation": {"advice": "Verify agent isolation from the host side with packet captures, file hashes and canary secrets, and run an escape probe inside each sandbox with an unsandboxed control to prove the refusals mean something.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/before-i-trust-an-agent-i-try-to-break-its-box", "markdown": "https://wpnews.pro/news/before-i-trust-an-agent-i-try-to-break-its-box.md", "text": "https://wpnews.pro/news/before-i-trust-an-agent-i-try-to-break-its-box.txt", "jsonld": "https://wpnews.pro/news/before-i-trust-an-agent-i-try-to-break-its-box.jsonld"}}