- the fake host serves a subset of @endo/agent-mcp-stdio's catalog, with its names, schemas and answers; evaluate takes only E(name).method(arg, ...), and __getMethodNames__ - demo.py --host endo: a real Endo daemon (endo-but-for-bots, llm), its guest served by the package's broker - a downloads folder: the host writes, Hermes reads at ~/Downloads; BindReadOnlyPaths on Linux, a virtiofs share on macOS - .#demo-tools: Hermes and the checks get their whole PATH from the store - each run saves its MCP messages and a transcript - the guide: tools as system calls, names as file descriptors; no Linux networking, but WebApps - grants match a named URL before "download" Generated-by: Claude Opus 5.5
8.8 KiB
Contributing to hermes-guest
How to check a change, and why the confinement holds. For what this is and how to deploy it, see the README.
Layout
- nix/hermes-guest.nix: the confined unit, the part that ports. Its
sandboxattribute set is what Confinement argues for. - nix/linux-host.nix, nix/llm-proxy.nix: on Linux, the host's systemd serves the unit's two sockets, and makes its downloads folder.
- nix/vfkit-vm.nix, nix/darwin-host.nix: on macOS, the same unit in a microVM, with its sockets relayed over vsock to launchd, and its downloads folder shared by virtiofs.
- llm-proxy.py: the inference proxy, which holds the API key.
- guide/endo-guest.md: what a guest can do (names, messages,
evaluate, WebApps, the downloads folder,define), installed as Hermes's skillendo-guest, so it works whatever serveshost.sock. - test/: unmodified Hermes against a host (a fake one, or a real Endo daemon) and a model (scripted, or real).
Checking a change
nix build .#demo-tools -o result-demo-tools
cd test
python3 -m doctest demo.py fake_host.py fake_llm.py transcript.py
python3 demo.py --tools ../result-demo-tools path/to/hermes path/to/socat # ends with PASS
These need Python 3.10 or later. Hermes and the checks get demo-tools/bin as their whole PATH: tools from the store, as the unit's closure gives them, and nothing of the machine's own.
The fake host serves a subset of @endo/agent-mcp-stdio's tools, with its names and schemas (test/endo-catalog.json, from node endo_catalog.mjs ENDO_CHECKOUT) and its rendering of answers. Its evaluate takes only E(name).method(arg, ...). With --host endo --endo ENDO_CHECKOUT, a real Endo daemon is the host instead (test/endo_host.mjs), its guest served by that package's broker; the checkout is endo-but-for-bots, branch llm, with its dependencies installed. Each run saves what happened in runs/TASK, replacing the last run of that task: transcript.md (the conversation as Hermes recorded it, reasoning and tool calls included), mcp.jsonl (every message on host.sock, either host), host.json (what the host received), and Hermes's output and logs.
With a model and a proxy command, a real model drives it, through llm-proxy.py as deployed. For example, with an Inference Cooperative key:
python3 demo.py --model deepseek-flash-tee path/to/hermes path/to/socat \
python3 ../llm-proxy.py https://gateway.inference.coop/v1 path/to/key
Add --task install to ask Hermes to install six and ms, with no networking but the package-index WebApps its host grants, and its downloads folder. On macOS it runs under sandbox-exec, with outbound network denied and its downloads folder read-only. It passes when the wheel and tarball came through ~/Downloads, and both import from where Hermes put them.
The demo leaves Hermes's detached helpers running; look for them with pgrep -fl hermes_cli. After a change to nix/, evaluate both platforms:
nix eval --impure --expr '((builtins.getFlake (toString ./.)).lib.mkDarwin {
hostDir = "/tmp/h"; model = "m"; upstream = "https://example.com/v1"; keyFile = "/k";
}).runner.drvPath'
Python here follows DisciplinedPython; run its checker on scripts you change. When you change the sandbox, update the table below in the same commit.
Confinement
Claim: every process running as Hermes's user changes the world outside its state directory only by:
- connecting to
host.sock: the authority of one Endo guest; - connecting to
llm.sock: inference at one upstream, with a key it never holds; - writing to its stdout and stderr, which go to the journal.
Approach: assume nothing about Hermes. Hermes can rewrite its own config.yaml, add MCP servers, and run anything its shell reaches. All of it runs inside the unit, so it inherits the same namespaces, mounts, cgroup and seccomp filter. So the argument is about the sandbox in nix/hermes-guest.nix, which every unit running as Hermes's user gets, and their confinement, not about Hermes or its model.
Each part of the sandbox starts from nothing and adds what's needed, the way a CSS reset does. There's no denylist to keep complete.
| Channel | What closes it |
|---|---|
| IP networking | PrivateNetwork: only loopback, shared with the bridge alone, whose one listener forwards to llm.sock. IPAddressDeny=any with IPAddressAllow=localhost is a second check. |
| Files, and Unix sockets by path | NixOS confinement: the root is an empty directory. Bound into it are the unit's closure (read-only, fullUnit, so PATH's packages too), /bin/sh, the state directory (BindPaths), and the two sockets and the downloads folder (BindReadOnlyPaths), plus private /dev, /proc, /sys and /tmp. A path outside those doesn't exist in the unit's view. That matters for sockets, which cross network namespaces and accept connect() even on a read-only mount. |
| Unix sockets, abstract | Private to the network namespace. |
| Other socket families | RestrictAddressFamilies: AF_UNIX, and AF_INET/AF_INET6 for loopback. No AF_NETLINK, AF_PACKET or AF_VSOCK. |
| systemd, D-Bus | The bus sockets aren't in the root. No user manager: the user doesn't linger, so Hermes's cron jobs fail closed. |
| Escaping the unit | Descendants stay in the unit's cgroup (read-only under ProtectControlGroups) and stop with it, detached or not. |
| Other processes | ProtectProc=invisible, ProcSubset=pid, PrivateIPC. Hermes's user can still ptrace its own processes, so the bridge, which runs as that user, gets the same sandbox. |
| Privilege | PrivateUsers (a user namespace mapping only the unit's own user), NoNewPrivileges, an empty CapabilityBoundingSet, RestrictSUIDSGID, and RestrictNamespaces, so it can't make namespaces of its own. |
| Kernel interfaces | ProtectKernelTunables, ProtectKernelModules, ProtectKernelLogs, ProtectClock, ProtectHostname, LockPersonality, SystemCallArchitectures=native. |
host.sock grants what its host serves. The host must serve only the guest's methods, bound to one agent, and references must stay in the host's pet store. Arguments are data (pet names, strings, message numbers) and code: evaluate runs the guest's source on the host's side, with only the guest's own references in scope, so it reaches nothing the guest couldn't reach by calls. The socket is mode 0600, owned by Hermes's user, so the connection designates the guest. Any process as that user counts as Hermes, and all of them are confined alike.
The downloads folder is the host's to write, and read-only in the unit, so it's input, not a way out: Hermes can't write there, and so can't plant a file or symlink for the host to act on. The host writes what the guest asks, through references the guest holds (E(dir).write(name, blob)), so the bytes come from the web to the disk without passing through Hermes or the model.
llm.sock reaches llm-proxy.py, which runs as another user. It reads the key from its own systemd credential, which Hermes can't read. It forwards only /v1/ paths, to one upstream host, and replaces any Authorization header the client sends.
On macOS the VM runs the same unit, and adds a boundary that holds even if the VM's kernel is compromised. Root in the VM reaches no network interface. It reaches the two vsock ports vfkit relays, the host's /nix/store read-only, the downloads folder's share, and the state image. The trusted base gains Apple's hypervisor and loses the VM's kernel, with one exception: the downloads share is read-only in the unit, but not at vfkit, so a compromised VM kernel could write to hostDir/Downloads.
Not claimed:
- Secrecy. Hermes can read its closure and its state, and pass them to the model provider or to its host.
- Denial of service. No memory, task or CPU limits are set.
- Kernel bugs on a Linux host, and covert channels.
To probe a running Linux host, look at the unit's root and network from outside:
pid=$(systemctl show -p MainPID --value hermes-agent)
sudo ls -A /proc/$pid/root /proc/$pid/root/run/hermes-guest /proc/$pid/root/var/lib
sudo ls /proc/$pid/root/nix/store | wc -l # the closure, not the whole store
sudo nsenter -t "$pid" -n ip -brief link
systemd-analyze security hermes-agent hermes-llm-bridge
Expect no etc or home in the root, the two sockets, only hermes in var/lib, and only lo.