Before it reads a byte of the VM's, devvm _proxy-child confines every
thread of itself through proxy.confineSelf on Linux: no_new_privs
(syscall.AllThreadsSyscall), Landlock from ABI 2 (TSYNC from ABI 8) to
its logs folder, the Nix cache and the resolver's files (never /, the
home folder or one that holds it), binding no TCP port (ABI 4), scoping
signals and abstract sockets (ABI 6, or ABI 6/7 with erratum 2),
refusing named unix sockets (ABI 9) and UDP but to port 53 (ABI 10);
then a hand-written classic BPF seccomp filter, installed with TSYNC,
that refuses with EPERM AF_UNIX socket/socketpair, listen, io_uring,
ptrace, process_vm_readv/writev, pidfd_getfd, a file's mode, owner,
xattrs and times by its path (chmod, fchmodat, fchmodat2, chown, lchown,
fchownat, the six xattr calls, utime, utimes, futimesat, utimensat with
a path), truncate, the keyrings (add_key, request_key, keyctl),
prlimit64 on any pid but 0, setpriority, ioprio_set,
sched_setaffinity, sched_setscheduler, sched_setparam, sched_setattr,
inotify_init, inotify_init1, inotify_add_watch, fanotify_init,
fanotify_mark, execve, execveat, fork, vfork, unshare, setns, bpf,
userfaultfd,
perf_event_open, clone for anything but a thread or with a namespace's
flag, and clone3 with ENOSYS; it kills a foreign architecture's call or
an x32 number. fchmod, fchown, ftruncate and utimensat on a descriptor
stay. It checks the confinement holds, then proxy.checkConfined, and
that it still reads the host's addresses, within 2 seconds, or fails
the start. A kernel without Landlock or seccomp leaves that part out;
the child runs and says so. The broker sets itself undumpable
(PR_SET_DUMPABLE 0). The Nix cache marks a file used through its
descriptor. The broker's start, and its life with the child, take a
reset of the socket (ECONNRESET, Linux's end of a socket closed with
frames unread) as the child's end, as EOF is (socketEnded,
TestHandshakeChildGone).
Built on the Seatbelt item's shared owner, proxy.Confinement:
- internal/landlock (new, stdlib only, Linux build tags): Self, Result,
Floor, ABIPorts/ABISignals/ABIUnix, ErrUnsupported; landlock_linux.go
(resolverFolders, refusedFolder, homeFolder), filter_linux.go (filter,
asm, encode, archOf), seccomp_linux.go, self_linux.go (Self, check,
refused).
- internal/proxy: confineSelf on Linux calls landlock.Self;
landlockConfinement words it (By landlock, seccomp; Why
no-landlock-or-seccomp, no-landlock, no-seccomp, landlock-below-abi4,
landlock-signals; full from ABI 6 with seccomp and scoped signals);
confineChild takes the child's needs and returns an error, bounded by
confineWait (within, confineWith); checkConfined only where Landlock
or Seatbelt confines files; confineStarted; IO.confine required, set
by ChildMain alone; hostAddrs.check; touch_linux.go and
touch_other.go (touchFile, undumpable); IO.dumpable for tests.
- devvm doctor: netpolicy.Unconfined's Linux warnings
(proxy_unconfined_no_kernel, _no_landlock, _no_seccomp, _old_ports,
_old_signals).
- Tests: TestFilter and TestFilterBytes (an interpreter of the program's
bytes, amd64 and arm64, and the assembler's refusals), TestSelf (a
real confined child: outside file, ssh-like unix socket, listen, bind,
signal, chmod, chown, setxattr, utimes, truncate, a keyring, unshare,
exec, clone3, and new threads, fchmod, ftruncate and futimens kept),
TestKernel, TestCheck, TestRights (refusedFolder), TestArchNumbers,
TestLandlockConfinement, TestConfineWithin, TestCheckConfined,
TestConfineStarted, TestRunChildOn, TestUnconfined; network.txtar; e2e
network's Landlock, NoNewPrivs and Seccomp check.
- CI: a nocgo job (CGO_ENABLED=0) for internal/landlock and
internal/proxy.
- Structure test, depguard, goroutineSites; docs: the child's sandbox,
processes (and its why-Go note on unsafe), design (the network row's loopback follow-up on Linux,
other processes and /proc without Landlock), doctor's checks,
troubleshooting, attack vectors, Contributing, the proxy's README,
AGENTS.md, CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>