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.
For review
Section titled “For review”- Decides: the answer to X27-vsock-confinementX27-vsock-confinement: vsock confinement of project usersCan a non-root process in a macOS guest open AFVSOCK, and bind or listen on wb-guestd's port while wb-guestd is running or being restarted? (I101I101 (closed): X27-vsock-confinement: vsock confinement of project usersThe B29-vsock-handoff decision (#29) is that the host opens every host-guest connection.), and what
S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., 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. and 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. now
state:
wb-guestdlistens on a vsock port below 1024, which only guest root (effective user ID 0) can bind, and the session profile denies creatingAF_VSOCKsockets with one named rule. - You are approving: the answer “yes, with conditions”, the
measurements, and the spec text in this pull request. Without the
conditions, a project user can pose as
wb-guestd: in the spike, a standard user took port 1024 while launchd restarted the daemon and answered the host in its place for 21.7 s. - Controls touched: none weakened. SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another. and SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter. gain the port rule, which the guest kernel enforces for every non-root process, also outside the Seatbelt profile. The Seatbelt rule is the second layer. 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. is unchanged: guest root can still bind the port, as it can already pose as any project user (T11-shared-vm-grantsT11-shared-vm-grants: Projects in one VM share network grantsThe host sees one guest address per VM, and can't tell which project user, session or program opened a connection.).
- Assumed: that the guest kernel’s rule for ports below 1024 stays
in later macOS releases. The rule isn’t in Apple’s developer documentation, but the XNU source has it
(
bsd/kern/vsock_domain.c,VSOCK_PORT_RESERVED,proc_suser). Condition 4 and its conformance check in 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… test it on each guest image. Also that 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)? can work with project users who have nosudo(condition 5). The maintainer is to confirm this strict default. - Open decisions: none.
- 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.
Question
Section titled “Question”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.
Answer
Section titled “Answer”Yes, with conditions. A project user can pose as wb-guestd when
nothing stops it, and two controls stop it.
- 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). - Ports below 1024 need root: yes.
bindon ports 1, 80, and 1023 fails withEACCESfor 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:bindbelowVSOCK_PORT_RESERVED(1024) returnsEACCESunlessproc_suserpasses, which checks for effective user ID 0 (bsd/kern/vsock_domain.c). - While
wb-guestdholds its port, nobody else gets it. Every variant fails withEADDRINUSEfor root and non-root alike: the wildcard CID, the guest’s own CID, andSO_REUSEADDRwithSO_REUSEPORT. Binding to the host’s CID fails withEADDRNOTAVAIL. - During a restart, a project user takes the port: yes, at 1024.
After
kill -9, launchd startedwb-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 triedbindevery millisecond got port 1024 first. It answered 410 of the host’s connections aswb-guestdfor 21.7 s. Meanwhile launchd restarted the real daemon every 10 s, and each start failed withEADDRINUSEand 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 withEACCESon all 2330 tries. - Seatbelt can deny it: yes. Under a profile with
(deny system-socket (socket-domain AF_VSOCK)),socket()fails withEPERM, 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 deniedsocket()both after and before an unconditional(allow system-socket)in the same profile. - Other Seatbelt rules don’t cover vsock creation.
(deny network*),network-bindandnetwork-inboundfailbindwithEPERM, andnetwork-outboundfailsconnect, but each leavessocket()and the CID ioctl working. A(deny default)profile withoutsystem-socketdeniessocket()too. - The agent-safehouse profiles, as rendered at the pinned commit,
deny vsock bind and connect but not
socket(). Their10-system-runtimemodule allows everysystem-socket, and20-networkallows network operations only on IP addresses and themDNSRespondersocket. 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:
wb-guestdlistens on a vsock port below 1024. Only guest root can bind it, so no project process can take it whilewb-guestdrestarts, 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 andlaunchdas running outside the profile.wb-hostdconnects only to that port.- The session profile denies
AF_VSOCKsockets 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. wb-guestdkeeps listening after a failedaccept. AnECONNABORTEDfromacceptis logged and skipped, never fatal, so a guest process that connects to the guest’s own CID can’t stop the listener.- 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
EACCESand that bindingwb-guestd’s port while it runs is refused. Inside a session, it checks that the profile deniessocket(AF_VSOCK). - Project users can’t become root. “Root” here means effective
user ID 0, which
sudogives. A project user is a standard account outside theadminandwheelgroups, 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 outsideadminandwheel, with no sudoers rule. The spike’s guest also had an admin account withsudo, 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.
Measurements
Section titled “Measurements”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(NSPOSIXErrorDomain54) from Virtualization. - A guest connection to a host port with no listener failed with
EAGAINrather thanECONNREFUSED. sysctldoesn’t list a vsock setting for the port rule, onlynet.vsock.sendspace,recvspace, andpcbcount.
What was not measured
Section titled “What was not measured”- Older or newer guests. Only macOS 27.0.1 ran. The port rule
isn’t in Apple’s developer documentation, but the XNU source has it
(
bsd/kern/vsock_domain.c,VSOCK_PORT_RESERVED,proc_suser), and condition 4 tests it per image. sandbox_initfromwb-guestd. The spike applied profiles withsandbox-exec, which uses the same kernel policy. Its children inherit the profile, as 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. states.- The full session profile. Only the agent-safehouse modules that its renderer selects by default ran, not the Wraith Box profile, which the Layer 2 work 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. generates.
- A process started through LaunchServices or
launchdas the project user. Condition 1 covers it without the profile, which the results above show for a process without one.
What it means for the specs
Section titled “What it means for the specs”- S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., “The VM provider passes descriptors, not
bytes”:
wb-guestd’s port is below 1024,wb-hostdconnects only to it, andwb-guestdkeeps listening after an abortedaccept. The line that called this untested now cites this result (changed in this pull request). - 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.:
wb-guestdlistens on a port below 1024 on vsock guests, project users are standard accounts with nosudo, and sealing fails on an enabled admin account (changed in this pull request). - 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., Layer 2: the rule in the profile, why the generic network rules aren’t enough, and that the port rule covers processes outside the profile (changed in this pull request).
- 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…: the conformance checks of conditions 4 and 5 (changed in this pull request).
Spike code
Section titled “Spike code”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