crabpot restricts what a process can read, write and reach on the network, using the OS's own sandbox and no container. It is a port of anthropics/sandbox-runtime (srt) to Rust, with no Node runtime, and reads the same settings file.
| Platform | How it confines a process |
|---|---|
| macOS | sandbox-exec with a generated profile |
| Linux | bubblewrap and seccomp (bwrap must be on PATH) |
| Windows | a separate sandbox user behind a WFP firewall fence, after a one-time install |
On every platform, network traffic goes through a filtering proxy that only lets the allowed domains through.
Install
Use it
Write a settings file, upstream's format:
Then run a command under it. With no -s, crabpot reads ~/.srt-settings.json, as upstream does.
-d prints debug output. Or use the library:
use Path;
use Command;
Sandbox::start refuses with a typed StartError that names what is missing. The sandbox's grants and proxy last until it drops.
Windows setup
The Windows sandbox needs a one-time install: the sandbox user, the WFP network filters and the read access the user needs. It is the same install as upstream's srt windows-install (same user, same WFP sublayer, same setup version), so an install by either tool satisfies the other.
crabpot windows-install [--allow-loopback] [--proxy-port-range LOW-HIGH]
[--sandbox-user NAME] [--sublayer-guid GUID] [--force]
[--profile-exclude PATH] [--skip-profile-grant]
crabpot windows-uninstall [--keep-user] [--sublayer-guid GUID]
windows-installasks for elevation itself, with one UAC prompt, and does the work in the elevated process.- After the install it makes the profile read grant, as upstream's install does: the sandbox user can then read your profile, except what srt-win keeps out on its own (
~\.ssh,~\.awsand the other key dot-directories, Windows' own per-user secret stores, browser profiles and password managers, your registry hives) and anything--profile-excludenames. What it opens includes package-manager configuration that can hold feed tokens (.npmrc,pip.ini,NuGet.Config,Maven settings.xml,gradle.properties,.gitconfig). The grant runs as you and needs no elevation. Its first pass touches every file it grants, which takes minutes on a large profile, and a new top-level item of the profile stays unreadable until it runs again.crabpot --srt-win profile forgetremoves the grant. --profile-exclude PATHkeeps one more path unreadable. Repeatable, and it reachessrt-win profile grantas--exclude: an exclusion once recorded stays in force.--skip-profile-grantmakes no grant. A crabpot under your profile, which is wherecargo installputs one, then stays unreadable to the sandbox user.- The install also makes no grant when it ran as a service account (LocalSystem, LocalService, NetworkService), when the owner of the session it ran in could not be read, or when that session belongs to another account, where granting would open the installing account's profile instead of the one the sessions in it read. Each prints the account it turned on.
- The install ends by checking that the sandbox user can read the crabpot executable, which it runs as the runner. The grant is what makes a binary under your profile readable, and a binary in a folder every user can read, such as one under Program Files, needs no grant at all. When the install made no grant, an unreadable runner is a notice naming
crabpot --srt-win profile grantand the install still exits 0, since skipping the grant is what you asked for. Sandbox::startrefuses an unreadable runner by name (StartError::RunnerUnreadable) before it grants anything, so the binary is named instead of seclogon answeringCreateProcessWithLogonW: Access is denied. It reads the executable's own access list for the sandbox account, the group it is in, and Users, Authenticated Users and Everyone, so a folder granted to the sandbox alone counts. Sitting under your profile is not enough on its own: the grant puts an inheritable entry on each folder it reaches, so what it excludes, what it leaves ungranted (your temporary directory) and any top-level item made after it ran are all refused. So is a binary moved in from another folder, which is whatcargo installdoes: it keeps its old access list, a new grant writes nothing for it, andicacls <path to the binary> /resetre-applies the folder's inherited entries. A host can read that same check before it starts anything:crabpot::windows_status()reports it asWindowsStatus::runner_readable,Nonewhen the machine could not make the check.--allow-loopbackopens every loopback port to the sandbox user, not only the proxy's. Every listener on localhost becomes reachable from the sandbox, including a forwarder that carries traffic off the machine. A session must use the loopback mode the install used, so changing it means running the install again with--force.--proxy-port-rangesets the loopback ports left open for the proxy (default60080-60089). Each sandbox takes two of them, so the default range holds five sandboxes at once, and a session that finds every port of its range taken refuses withStartError::ProxyRangeFull, which names the range and the flag.windows-uninstallremoves the user, its credential and the filters, and with them the profile read grant (--keep-userkeeps the user and the grant). It then removes any WFP filters left under the sublayer.- Both commands are for Windows and refuse on any other platform.
License
MIT OR Apache-2.0, at your option.
crabpot is derived from anthropics/sandbox-runtime, which is Apache-2.0. See NOTICE.