Skip to content

X27 - vsock confinement of project users

Purpose: Whether a project user’s process in a macOS guest can open AF_VSOCK and take wb-guestd’s port, and whether the Seatbelt profile of S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. can stop it.

Brief: B101-vsock-confinementB101-vsock-confinement: Can a project user take wb-guestd's place on the host-guest socket?Yes, unless two controls stop it.

From X00-indexX00-index: SpikesThe open questions that must be answered by a throwaway prototype before work builds on them, in the order they are taken up.: can a non-root process in a macOS guest open AF_VSOCK, and bind or listen on wb-guestd’s port while wb-guestd is running or being restarted? Can the Seatbelt profile of S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. deny AF_VSOCK to project users? I101I101 (closed): X27-vsock-confinement: vsock confinement of project usersThe B29-vsock-handoff decision (#29) is that the host opens every host-guest connection. adds: measure how long wb-guestd’s port is free when launchd restarts it after a kill.

Yes, with conditions. A project user can pose as wb-guestd when nothing stops it, and two controls stop it.

  1. A non-root process can open AF_VSOCK: yes. A standard user (not an admin) and an admin user both create vsock stream sockets, read the guest’s CID (3) with the ioctl, and connect to a host listener. Datagram sockets fail for everyone (EPROTONOSUPPORT).
  2. Ports below 1024 need root: yes. bind on ports 1, 80, and 1023 fails with EACCES for both non-root users and works for root. From 1024 up, any user binds any free port. An automatic port (VMADDR_PORT_ANY) is taken from 1025 up, for root too. The XNU source has the same rule: bind below VSOCK_PORT_RESERVED (1024) returns EACCES unless proc_suser passes, which checks for effective user ID 0 (bsd/kern/vsock_domain.c).
  3. While wb-guestd holds its port, nobody else gets it. Every variant fails with EADDRINUSE for root and non-root alike: the wildcard CID, the guest’s own CID, and SO_REUSEADDR with SO_REUSEPORT. Binding to the host’s CID fails with EADDRNOTAVAIL.
  4. During a restart, a project user takes the port: yes, at 1024. After kill -9, launchd started wb-guestd’s stand-in again and the host reached it 11.5 to 18.2 ms after its last answer from the old process (five runs, host connecting every 5 ms). A standard user that tried bind every millisecond got port 1024 first. It answered 410 of the host’s connections as wb-guestd for 21.7 s. Meanwhile launchd restarted the real daemon every 10 s, and each start failed with EADDRINUSE and exited. After the squatter exited, nothing answered on the port for 8.2 s, until launchd’s next try. On port 1023 the same squatter failed with EACCES on all 2330 tries.
  5. Seatbelt can deny it: yes. Under a profile with (deny system-socket (socket-domain AF_VSOCK)), socket() fails with EPERM, so no bind, listen, connect, or ioctl follows. The squatter, run under that profile, failed at once, and the host reached the restarted daemon 54 ms after the old one’s last answer. The symbolic name and the number 40 work the same. The rule denied socket() both after and before an unconditional (allow system-socket) in the same profile.
  6. Other Seatbelt rules don’t cover vsock creation. (deny network*), network-bind and network-inbound fail bind with EPERM, and network-outbound fails connect, but each leaves socket() and the CID ioctl working. A (deny default) profile without system-socket denies socket() too.
  7. The agent-safehouse profiles, as rendered at the pinned commit, deny vsock bind and connect but not socket(). Their 10-system-runtime module allows every system-socket, and 20-network allows network operations only on IP addresses and the mDNSResponder socket. With the rule of 5 added at the end, socket() fails too.

A guest process can’t reach wb-guestd through its own CID either: connect to the guest’s own CID returned success while the daemon listened, but the daemon’s accept failed with ECONNABORTED, so the daemon didn’t get a connection from it. With nothing listening, connect failed with EINVAL.

The conditions:

  1. wb-guestd listens on a vsock port below 1024. Only guest root can bind it, so no project process can take it while wb-guestd restarts, also outside the Seatbelt profile: S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. lists processes started through LaunchServices and launchd as running outside the profile. wb-hostd connects only to that port.
  2. The session profile denies AF_VSOCK sockets with (deny system-socket (socket-domain AF_VSOCK)), so a project process can’t use vsock at all. That keeps it off every other guest port the host might connect to later.
  3. wb-guestd keeps listening after a failed accept. An ECONNABORTED from accept is logged and skipped, never fatal, so a guest process that connects to the guest’s own CID can’t stop the listener.
  4. The guest kernel’s port rule is tested on every image. The conformance suite of S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq… checks, as a project user outside the session profile, that binding a free port below 1024 fails with EACCES and that binding wb-guestd’s port while it runs is refused. Inside a session, it checks that the profile denies socket(AF_VSOCK).
  5. Project users can’t become root. “Root” here means effective user ID 0, which sudo gives. A project user is a standard account outside the admin and wheel groups, with no sudoers rule. Sealing fails on an enabled admin account or an added sudoers entry, so the image build disables or removes any admin account it creates (S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does.). The spike’s project user stand-in was outside admin and wheel, with no sudoers rule. The spike’s guest also had an admin account with sudo, which could bind any port and so defeat condition 1. X20-shared-homebrewX20-shared-homebrew: Homebrew with more than one project userCan each project user in one guest get its declared Brewfile without a Homebrew prefix that another project user can write to (SEC08-proj-isolation)? has to work within this.

Host: Apple M2, 16 GB, macOS 27.0.1 (26A434), Xcode 27.0 (Swift 6.4), Go 1.27.1, golang.org/x/sys 0.48.0. Guest: macOS 27.0.1 (26A434), 4 vCPU, 4 GiB, SIP on, a fresh clone of X18-vsock-handoffX18-vsock-handoff: Host-guest socket and descriptor hand-offCan wb-guestd, written in Go, open AFVSOCK sockets in a macOS guest?’s installed bundle, with a NAT network for SSH and a VZVirtioSocketDevice. The wb-guestd stand-in ran as a root LaunchDaemon with KeepAlive. The project user stand-in was a standard user (uid 502, not in admin). Every call ran without a Seatbelt profile unless a profile is named.

Call, as the project user No profile deny system-socket AF_VSOCK deny network* safehouse v0.12.0
socket(AF_VSOCK, SOCK_STREAM) ok EPERM ok ok
CID ioctl ok (3) (no socket) ok ok
bind port 1023 EACCES (no socket) EPERM EPERM
bind port 1024, free ok (no socket) EPERM EPERM
bind port 1024, held by root EADDRINUSE not run not run not run
connect host listener ok (no socket) EPERM EPERM
Restart of the wb-guestd stand-in after kill -9 Result
Host sees the new process, nobody squatting (5 runs) 11.5, 11.7, 12.6, 13.3, 18.2 ms after the old one’s last answer
Project user squatting port 1024 won after 3.2 s of trying, 2532 tries, then answered the host 410 times over 21.7 s
Real daemon’s restarts while squatted 3, 10 s apart, each EADDRINUSE
Project user squatting under the deny system-socket rule EPERM on the first socket(); host reached the new daemon 54 ms after the old one’s last answer, polling every 50 ms
Project user squatting port 1023 for 3 s, nothing bound EACCES on all 2330 tries
  • The host’s connection attempts while the port was free failed with ECONNRESET (NSPOSIXErrorDomain 54) from Virtualization.
  • A guest connection to a host port with no listener failed with EAGAIN rather than ECONNREFUSED.
  • sysctl doesn’t list a vsock setting for the port rule, only net.vsock.sendspace, recvspace, and pcbcount.

Branch spike/x27-vsock-confinement, at edf2f33: the Swift wb-vmd stand-in with its control socket, the Go wb-guestd stand-in and probe, the provisioning script, the Seatbelt profiles, the experiment script, and the raw results in results/ with who answered when in results/gap-summary.txt.

Status: Answered 2026-10-06: yes, with conditions