Skip to Content
kumoba

How it works

Your code calls kumobad over HTTP. kumobad starts one kumoba-worker per sandbox, and each worker boots a VM with its own kernel and talks to the kumoba-guest agent inside it over vsock. Each sandbox's disk comes from an image.

In brief

  • Your code uses the kumoba CLI, the TypeScript SDK, the Rust library or plain HTTP. They all talk to one daemon, on a Unix socket or a loopback port, or over TLS from another machine.
  • kumobad, the daemon, keeps track of every sandbox, holds secrets in memory, signs browser links and keeps the access log. For each sandbox you start, it starts a worker.
  • kumoba-worker boots one VM with libkrun, on KVM on Linux or Hypervisor.framework on macOS, and runs that VM's network proxy.
  • The VM has its own kernel and its own disk, and no network card: its traffic goes through the worker's proxy, which applies the sandbox's network rules and logs every connection.
  • kumoba-guest, the guest agent, is the first process in the VM. It runs commands and reads and writes files for the host, over vsock.
  • An image is a disk to boot from. The default image is Debian with Python, Node, Chromium and a desktop. A sandbox's disk starts as a clone of the image, or a thin layer over it, so creating a sandbox doesn't copy the whole image.

A sandbox lives through create (its disk is made), start (a worker boots the VM), exec, shell and file calls, stop (the VM shuts down and the disk stays) and delete. kumoba run does all of it in one call. A macOS sandbox works the same way, with Apple's Virtualization framework in place of libkrun.

The rest of this page goes into detail.

Processes

  • kumobad is the daemon. It keeps sandbox state, serves the HTTP API, and every 30 seconds stops idle sandboxes and deletes expired ones.
  • kumoba-worker runs once per running VM. It loads libkrun, boots the VM and hosts that VM's egress proxy. If the daemon dies, the worker shuts its VM down.
  • kumoba-guest is the first process inside each VM. It runs commands, reads and writes files, and opens tunnels to guest ports for the host. It also offers a proxy on 127.0.0.1:3128, so tools inside the VM reach the network without a network card.

Host and guest talk over vsock with length-prefixed JSON frames. Each operation opens its own connection, so a long command never blocks a file read. The protocol is version 3; a guest with another version is refused.

Disks

An image is a raw ext4 filesystem. kumobad first keeps one private, read-only copy of each version of an image in runtime/bases/. Where the state directory's filesystem can clone files (APFS, XFS, Btrfs), that copy is a clone, which uses no space of its own. On a filesystem that can't clone, such as ext4, it is a real copy of the used blocks, made once per image version. On a Mac, and on a Linux filesystem that can't clone, each sandbox gets a qcow2 layer over the shared copy: the guest reads the shared copy until it writes, and its writes go only to the layer. On XFS and Btrfs each sandbox's disk is a clone of the shared copy instead, which costs nothing until the guest writes. A Mac uses layers because on APFS the first write to a fresh clone of a large image, and freeing a clone that the guest wrote to, each take time in proportion to the image's size, about 0.2 s each for the default image, and the volume runs them one at a time, so sandboxes created or deleted together waited for each other. A new sandbox then takes milliseconds and uses about the space it writes, and deleting it frees its layer. The shared copy stays while its image is unchanged; once the image changes, or for a sandbox restored from a snapshot that was deleted since, the old copy is freed with the last sandbox that still uses it. GET /v1/info reports which of the two the host uses as diskMode, and kumobad makes the shared copy of every configured image in the background, unless that would leave less than KUMOBAD_MIN_FREE_DISK_MIB plus 2 GiB free, so it never takes the space creates and running sandboxes need. KUMOBAD_DISK_MODE=copy goes back to a full copy for every sandbox.

kumoba writes each layer itself with all of its tables in place, so the VMM only ever fills in entries and never moves metadata. If a sandbox's VM was killed instead of stopped, kumoba checks and rebuilds the layer's cluster counts before it boots again, and refuses to boot a layer whose tables are not the ones it wrote. Snapshots stay raw images: snapshotting a sandbox with a layer writes its layer over a copy of the shared disk, and restoring a snapshot links its disk as the shared copy, without copying it. Sandboxes created by an earlier kumobad keep their full copies. A stopped sandbox keeps its disk.

Network

A guest has no network device. Its traffic goes through the worker's proxy, which applies the sandbox's policy (open, allowlist or blocked) and always refuses private addresses. TLS stays end to end, except for hosts with a secret: the proxy terminates those with a per-daemon CA that the guest trusts, so it can add the secret to the request. See Control network access and How secrets work.

Every connection attempt goes to an access log under the state directory, marked allowed, denied, or failed when an allowed destination could not be reached. kumobad keeps 72 hours of it.

Previews

A preview link is a signed token for one sandbox, port and expiry. Requests to it are relayed to the guest port, WebSockets included. Browsers load previews from a separate listener so pages from a sandbox never share the API's origin.

Live view

kumoba-view runs inside the guest next to the desktop and listens on loopback. A browser reaches it through a preview link, like any other guest port.

  • It waits for the X server to report a change, then reads only the changed rows through shared memory.
  • It keeps a copy of what the browser shows. Each frame is the difference from that copy: areas that moved, pixels coded exactly, and blocks of busy content coded with loss. Lossy blocks are sent exactly once they stop changing.
  • The browser decodes frames with the same Rust code, built as WebAssembly, and draws one whole frame per screen refresh.
  • The browser acknowledges every frame. From the delay of those acknowledgements the engine sets how many frames may be on the way and how many bytes a second it may send.

A macOS sandbox has nothing inside it that may read the screen, so its engine runs on the host.

  • kumoba-worker puts the VM's display in a window that is never shown. When asked, it copies the current frame into shared memory, and it passes key and pointer events to the VM's keyboard and pointer.
  • kumobad starts kumoba-view-host on the first desktop link. It reads frames from the worker, encodes them the same way, and serves the viewer on a socket in the sandbox's private directory.
  • The desktop link's token says it is a live view, and kumobad relays it to that socket instead of a guest port. The engine exits when the sandbox stops.
  • The worker also sends the pointer shape macOS sets, read from the same hidden view. For paste, copy and characters the US keyboard layout lacks, it reads and writes the signed-in user's clipboard by running pbcopy and pbpaste through the guest agent.

State directory

<KUMOBAD_STATE_DIR>/
  meta/<id>.json        sandbox metadata
  preview.key           key that signs preview links
  access/               access log, one file per hour
  runtime/
    bases/              one shared copy of each image version
    sandboxes/<id>/     disk or layer, worker socket, console log
    snapshots/<id>/     snapshot disks

Secrets live only in the daemon's memory. Clients send them again after a restart.

Platforms

  • macOS uses Hypervisor.framework. The worker is signed with the hypervisor entitlement.
  • Linux uses KVM with libkrun 1.19.8 plus a vsock patch that kumoba ships, and libkrunfw 5.6.4 (Linux 6.12.115). The release tarballs include both.

Last updated on

On this page