Skip to content

R04 - Matchlock

Purpose: What matchlock is, how it relates to Wraith Box, which of its threats and defenses Wraith Box lacks, and what to do about it. Read at matchlock commit 77e02f6 (0.2.17, July 2026).

Requirements: SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise., SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.

Matchlock (jingkaihe/matchlock, MIT, first commit February 2026, 0.2.17 on 2026-07-26) is “a CLI tool for running AI agents in ephemeral microVMs - with network allowlisting, secret injection via MITM proxy, and VM-level isolation”. The README marks it experimental. One author wrote 497 of its 516 commits, under two spellings of one name.

  • One Go program. matchlock run --image alpine:latest pulls an OCI image, turns it into an ext4 root disk and boots it with matchlock’s own Linux kernel: Firecracker on Linux hosts, and Virtualization.framework through the Code-Hex/vz bindings on macOS. A guest agent in the VM runs commands over vsock. A JSON-RPC mode (matchlock rpc) drives Go, Python and TypeScript SDKs, which embed it in other programs.
  • Network. Without --allow-host, --secret or --network-intercept, a macOS guest gets Virtualization.framework’s NAT with no policy at all (pkg/vm/darwin/backend.go). With any of them, a gVisor userspace stack on the host terminates the guest’s frames (pkg/net/stack_darwin.go). Port 443 is always decrypted with a per-VM CA, port 80 is parsed as HTTP, and any other TCP port is relayed when its destination IP matches the allowlist. On Linux, nftables redirects ports 80 and 443 of a TAP device to the same proxy.
  • Secrets. --secret NAME@host puts a placeholder in the guest’s environment. The proxy swaps it for the secret in the headers and query string of requests to the hosts the flag lists, and refuses a request with the placeholder in a header or URL to any other host (pkg/policy/engine.go).
  • Files. -v host:guest serves a host directory to the guest over a FUSE-over-vsock protocol (pkg/vfs/server.go). The default mode copies the directory to a snapshot first. host_fs serves the host directory itself, read-write.
  • Hooks. SDK callers can attach rules to network requests and responses (block, or rewrite headers, query, path and body) and to file operations (block, rewrite a write, or run code after one). docs/network-interception.md and docs/vfs-interception.md describe them.

Matchlock has no threat model document. adrs/001-local-image-build.md takes the stance Wraith Box takes: the VM is the security boundary, and the seccomp filter and dropped capabilities in the guest are defense in depth, not the isolation.

Matchlock Wraith Box V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.
Users Programs, through SDKs, and the CLI One developer, through wb
Agents Any command in an OCI image Claude Code (V1-02-claude-onlyV1-02-claude-only: Claude Code onlyClaude Code is the supported agent.)
Guest Linux, from any OCI image, booted fresh each run macOS with Xcode, persistent (FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode).)
Hosts Linux with KVM, macOS on Apple Silicon macOS (S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL.)
Egress Open by default. With an allowlist: inspected HTTP and HTTPS, other TCP by IP Default deny with TLS inspection on the host (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.)
DNS On the userspace stack, every query relayed to 8.8.8.8 by default Answered by wb-netd for allowed names only (S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget.)
Credentials Placeholder replaced in any header or the query string of a bound host Injected in the binding’s header only, on named paths (S07-09-placeholder-bindingS07-09-placeholder-binding: Placeholder BindingWhere a credential placeholder may go in a request, how wb-proxyd scans for it, and what it refuses.)
Host files Host directories served to the guest, as a copy or live None (SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise.)
Returned work The agent pushes with the user’s token, or writes a live mount A branch in a landing repository (FR03-work-as-branchFR03-work-as-branch: Work returns as a branchThe agent never writes to the host working tree.)
Audit In-memory events to the SDK caller, dropped when the buffer is full OCSF 1.8.0 JSONL on the host (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.)

Overlap. Both put an agent in a VM, terminate its network on the host, inspect TLS with a CA of their own, and keep credentials on the host behind placeholders. The examples/claude-code/ helper runs Claude Code in a matchlock VM against a GitHub repository, which is the job of wb claude. Their users differ, though. Matchlock is a sandbox library for running generated code in throwaway Linux VMs. Wraith Box is a persistent macOS workstation for one developer’s Claude Code sessions. Matchlock competes with Wraith Box only for a user who wants a Linux toolchain and accepts its defaults.

Shared ancestry. Both attach a socket pair to the VM as its network device on macOS, and run gVisor’s pkg/tcpip on the host in promiscuous and spoofing mode (S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections., X03-network-pathX03-network-path: Network pathA macOS guest boots on the file-handle attachment with the gVisor stack: gets a DHCP lease, resolves only allowlisted names, reaches only the proxy.). Matchlock has no link filter in front of the stack, so gVisor answers ARP for every address, as B17-network-pathB17-network-path: Does a macOS guest work on our userspace network stack, reaching only the proxy, and how fast?Yes, with conditions. found. Its Linux guest gets a static address on the kernel command line, so it doesn’t hit the address conflict that made Wraith Box add the filter. Matchlock uses none of the OpenShell artifacts or OCSF, so it doesn’t share a schema with Wraith Box.

No integration point. Matchlock’s VM backend interface (pkg/vm/backend.go) is a Go interface inside its own process, with no contract another program could serve. Its Linux backend needs cap_net_admin and cap_net_raw on the binary, membership of the kvm and netdev groups and a TAP device (cmd/matchlock/setup_linux.go). X10-linux-hypervisorX10-linux-hypervisor: Linux VMM and packet transportPick a permissively licensed VMM over KVM that supports vsock, save/restore, copy-on-write disks, and a virtual TPM (for Windows guests), and a way to deliver guest Ethernet frames to wb-netd as an unprivileged user (… rules out the TAP device and cap_net_admin for Wraith Box, and SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts. rules out file capabilities on the binary. Access to /dev/kvm through the kvm group is something S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed. also accepts.

Matchlock is useful as a worked example of the threats Wraith Box’s specs already name. Each item below is a rule of Wraith Box that matchlock doesn’t have, read from matchlock’s code and not tested.

Threats matchlock covers that Wraith Box doesn’t

Section titled “Threats matchlock covers that Wraith Box doesn’t”

None. Matchlock’s defenses are a subset of Wraith Box’s: VM isolation, an allowlist, TLS inspection and placeholders. It has no threat model that names a risk Wraith Box’s T00-indexT00-indexboundary 6 is the host terminal stream. lacks. Its in-guest restrictions (dropped capabilities, a seccomp filter, a PID namespace per command) protect its guest agent from the command it runs. Wraith Box gets that from running wb-guestd as root and each project as its own user, and doesn’t rely on it (SEC11-root-gains-nothingSEC11-root-gains-nothing: Guest root is not a privilegeFull control of the guest grants no control over enforcement, secrets, or policy.).

Matchlock has some features that Wraith Box has deferred or not designed:

In the NIST Cybersecurity Framework functions that R01-defenseclawR01-defenseclaw: DefenseClawWhat Cisco's DefenseClaw is, how it relates to Wraith Box, which of its threats and defenses Wraith Box lacks, and what to do about it. uses, matchlock is almost all Protect, like Wraith Box. Its Detect is the event stream to the SDK caller, which a program could watch, but it drops events under load and keeps none. Its Respond is matchlock allow-list delete on a running VM, and matchlock kill. It adds nothing to the open question R01-defenseclawR01-defenseclaw: DefenseClawWhat Cisco's DefenseClaw is, how it relates to Wraith Box, which of its threats and defenses Wraith Box lacks, and what to do about it. raised: which layer detects what, and what a finding makes Wraith Box or the user do.

Status: Read 2026-10-23, no follow-up issues