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.
What matchlock is
Section titled “What matchlock is”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:latestpulls 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 theCode-Hex/vzbindings 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,--secretor--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@hostputs 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:guestserves 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_fsserves 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.mdanddocs/vfs-interception.mddescribe 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.
How it relates to Wraith Box
Section titled “How it relates to Wraith Box”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.
Where Wraith Box’s controls differ
Section titled “Where Wraith Box’s controls differ”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.
- Default open egress. Without an allowlist, a macOS guest has
NAT to the internet, the LAN and the host. With interception forced
and no hosts, an empty allowlist “means allow all hosts”
(
docs/network-interception.md). Theclaude-dangerexample allows*unless the user passes--allowed-host. - DNS. The gVisor userspace stack relays every UDP query on port
53 to
8.8.8.8or8.8.4.4by default (--dns-serversoverrides them), whatever the allowlist says. That is the DNS tunnel that SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. forbids. Wraith Box answers only allowed names and bounds lookups under a wildcard (T02-dns-namesT02-dns-names: Data in DNS namesData encoded in DNS names under allowed wildcards, bounded by a lookup budget per VM (S07-03-dns).). - Upstream addresses.
isPrivateIPresolves the name, checks only the first address, treats a failed lookup as public, and the dial resolves the name again. Its ranges leave out CGNAT,0.0.0.0/8, NAT64 and the host’s own addresses. Wraith Box checks every address against a longer list and connects only to the address it checked (S07-07-hosts-and-modesS07-07-hosts-and-modes: Hosts and ModesHow wb-proxyd binds a stream to its name, which upstream addresses it refuses, and the inspect, pass and audit modes., “Upstream address”). - SNI and
Host. On port 443, the allowlist, the hook rules and the secret’s host all use the SNI. TheHostheader of each request on that connection isn’t compared with it. Where the allowed host shares a front end that routes byHost, such as some CDNs, a request can reach another site behind it with the secret injected. Wraith Box requiresHostor:authorityto equal the stream’s name (S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones.). - Where a secret goes. Matchlock replaces the placeholder in every
header and in the query string of a bound host. A response that
echoes a header or the query, such as an error page or a redirect,
brings the secret itself into the guest. The
claude-dangerexample adds the user’s subscription access token to every request toapi.anthropic.comandplatform.claude.com, on every path. Wraith Box injects in the binding’s header only, on the paths X01-model-credentialX01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? saw Claude Code use, and removesSet-Cookiefrom the responses of a bound host (S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones.). - Repository writes. The
claude-codeexample binds the user’s GitHub token togithub.comandapi.github.comand starts Claude Code with--dangerously-skip-permissions. The guest can then do whatever the token allows, in any repository the user can reach. Matchlock doesn’t scope repository writes (SEC06-repo-writesSEC06-repo-writes: Repository-scoped writesGit pushes and repository-mutating API calls are allowed only for the repositories of the projects that have a session in the VM.). - Host files.
pkg/vfs/realfs.gojoins the guest’s path to the mount root and callsos.Statandos.OpenFile, which follow symbolic links on the host. The guest can’t create a link through the protocol (the server answersENOSYS), but a link already in the mounted tree is followed for reads and writes. The default copy mode keeps links as links, so an absolute link to~/.sshin a repository opens the host’s~/.sshto the guest. SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise. avoids the whole class. - Guest-written disks.
matchlock buildkeeps a BuildKit cache disk that guests write, and runse2fsck -fyandresize2fson it on the host to grow it (cmd/matchlock/cmd_build.go). It then imports the image tarball the build guest wrote. 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. forbids the first. S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage. never mounts or reads a filesystem or archive the build guest wrote: it clones the checked disks whole. - Bounds. The VFS server reads a 4-byte length from the guest and allocates that many bytes, and a read allocates the size the guest asks for, up to 4 GiB each. The repository has no fuzz targets. SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped. and S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs. cap both.
- Audit. Network and file events go to a channel of 100 and are
dropped when it is full. They reach only an SDK caller, and the CLI
keeps none. Byte counts come from
Content-Length, so a chunked upload counts as zero. SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter. asks for a persisted log of every decision.
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:
- Host-side subscription login.
examples/claude-danger/reads the host’s Claude Code OAuth credentials, refreshes the access token on the host, writes the new tokens back, and injects the access token with a network hook. The guest only sees a placeholder API key. This is close to the design of I257I257 (open): Host-side browser login for the model credential (after V1)A host-side browser login for the model credential, deferred past V1 by the B15-browser-login decision on #15 (2026-10-15, option B not chosen for V1)., which S09-05-credentialsS09-05-credentials: CredentialsHow credentials are stored and bound to requests, and how the model credential reaches the model API without entering the guest. and S14-04-commands-and-endpointsS14-04-commands-and-endpoints: Commands and EndpointsWhich permission mode Claude Code runs in, the commands that don't work in a guest, the guest instructions that explain the guest's limits to Claude Code, and the endpoints Claude Code in the guest may reach. defer until after V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. The example shows the refresh works from outside Claude Code. It also shows the risk of injecting on every path, which I257I257 (open): Host-side browser login for the model credential (after V1)A host-side browser login for the model credential, deferred past V1 by the B15-browser-login decision on #15 (2026-10-15, option B not chosen for V1). has to avoid by keeping the binding on the paths X01-model-credentialX01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? lists. - Request and response rules. Rules with a phase (before or
after), an action (allow, block or mutate) and matchers for host,
method and path, plus callbacks in the SDK process
(
pkg/policy/network_hooks.go). Rewrites of atext/event-streamresponse apply to eachdata:line, so they keep the stream’s framing. This rule model would fit the content rules inwb-proxydthat 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. lists as a detection layer. - Throwaway VMs. A matchlock VM boots from an image “in under a
second”, by its README, and is deleted after the command unless
--rm=falseis given.--no-networkstarts a VM with no network device. Wraith Box’s ephemeral sessions (FR14-ephemeralFR14-ephemeral: Ephemeral sessionsAn ephemeral mode runs a session with no persisted state.) have no milestone. - Port forwarding.
matchlock port-forwardbinds host loopback by default and relays plain TCP for the ports the user names. That is option B of B38-port-forward-clipboardB38-port-forward-clipboard: How should guest dev servers and clipboard text cross to the host?Forward HTTP through a host proxy that gives each forwarded port its own localhost site, plain TCP only on ports the user names, and the clipboard only through wb with an approval., which the brief says weakens SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential. through cookies onlocalhost. Port forwarding is out of V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. (V1-08-no-forward-clipboardV1-08-no-forward-clipboard: No port forwarding or clipboardPort forwarding (FR11-port-forward) and the clipboard (FR12-clipboard) are out of scope for V1, so nothing new crosses the VM boundary for them (S06-vm-lifecycle).).
Detection and response
Section titled “Detection and response”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.
Recommendations
Section titled “Recommendations”- Don’t integrate with matchlock. It has no contract another program could serve or call, and its Linux backend needs a TAP device and file capabilities, which 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 (… and SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts. rule out.
- Don’t take its egress or file designs. The differences above
each follow a rule Wraith Box already has. Matchlock is a reminder
of why those rules are there, and a source of review cases for
wb-netdandwb-proxyd: DNS outside the allowlist, a checked address that the dial doesn’t use, aHostthat differs from the SNI, and a placeholder echoed back in a response. - Use the subscription example when I257I257 (open): Host-side browser login for the model credential (after V1)A host-side browser login for the model credential, deferred past V1 by the B15-browser-login decision on #15 (2026-10-15, option B not chosen for V1). is designed. It shows a working host-side refresh, and what to avoid in the binding.
- Keep matchlock in mind for Linux guests. When 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 (… and X16-openshell-linuxX16-openshell-linux: OpenShell for Linux guestsCould OpenShell's VM driver (libkrun, guest without a network device, egress over vsock) run Linux guests for Wraith Box on macOS and Linux hosts instead of a VMM chosen in X10-linux-hypervisor? run, matchlock is a data point for booting OCI images quickly on both hosts. It doesn’t meet their constraints as it is.
- No follow-up issues. None of this needs a spec change. If the maintainer wants matchlock looked at again, the re-review after V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. (I240I240 (open): Re-review the research notes on related projects after V1 and fold their recommendations into post-V1 plansAfter V1 ships, review the recommendations of the research notes that compare Wraith Box with related projects, and fold the ones that still hold into the post-V1 plans.) can include it.
Status: Read 2026-10-23, no follow-up issues