X20 - Homebrew with more than one project user
Purpose: Whether each project user in one macOS guest can get its project’s Homebrew packages from a prefix that no other project user can write to, and what a prefix per project user would cost instead.
For review
Section titled “For review”- Decides: the answer to 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)? (I31I31 (closed): X20-shared-homebrew: Homebrew with more than one project userX20-shared-homebrew (added to S11-verification-and-spikes in #14)), and how 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., now describes the toolchain prefix and the project layer. It confirms the I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3. decision (the shared prefix belongs to a toolchain user) for how projects add packages.
- You are approving: the answer “yes, with conditions”, and the
spec text in this pull request. One prefix,
/opt/homebrew, belongs to the toolchain user.wb-guestdinstalls every project’s declared packages into it as that user. Project users can read and run it but can’t install packages, and the agent runs as a project user. The strongest of the conditions is that the manifest is read as a list of package names. A Brewfile is Ruby: run withbrew bundle, it ran a command as the toolchain user and wrote into the prefix that every project runs from. - 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. gains the
manifest rule: without it, any project’s Brewfile could plant a
binary that other projects run. A new threat,
T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain
prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix")., accepts that every project’s tools rest on
homebrew/core. Projects in one VM share the versions in the prefix, much as they share network grants (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.). The spike didn’t measure whether a project can change what another project’s session runs while it runs (condition 4). - Assumed: that the conditions the spike didn’t try work as written:
Homebrew’s temporary and cache folders in the toolchain user’s home,
the pinned formula data keeping a reconcile from upgrading kegs other
projects use, and a session
PATHwithout the prefix’s sharedbin. I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user. measures all three in a guest. The spike used a NAT network, not the egress gateway, and the toolchain user name_wbtoolis a stand-in until I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3. picks one. - Decisions: both decided 2026-10-08 as recommended, in the I31I31 (closed): X20-shared-homebrew: Homebrew with more than one project userX20-shared-homebrew (added to S11-verification-and-spikes in #14)
comment that starts
Decision (2026-10-08):.- Whether a project may get a prefix of its own instead, where the
agent can run
brew install. It works when the path is at most 13 characters long, such as/opt/wbp-c, and every bottle then pours. Recommended: not in v1. The shared prefix covers declared packages,--isolatedcovers conflicts, and an agent that installs packages is a capability v1 doesn’t need. Decided 2026-10-08 (I31I31 (closed): X20-shared-homebrew: Homebrew with more than one project userX20-shared-homebrew (added to S11-verification-and-spikes in #14)): no per-project prefix in v1. - Whether to refuse packages without a bottle for the guest. Bottles
only:
wb-guestdchecks every formula in the closure and refuses the session with the name of one that has none, so a package without a bottle can’t be declared. Building from source instead means slow starts, builds killed at the start deadline, and more ofhomebrew/core’s code run as the toolchain user (T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix").). Recommended: bottles only, which the spec says now. Decided 2026-10-08 (I31I31 (closed): X20-shared-homebrew: Homebrew with more than one project userX20-shared-homebrew (added to S11-verification-and-spikes in #14)): bottles only.
- Whether a project may get a prefix of its own instead, where the
agent can run
- Brief: B31-shared-homebrewB31-shared-homebrew: Can projects in one guest share Homebrew without being able to change each other's tools?Yes, with conditions.
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 each project user in one guest get its declared
Brewfile without a Homebrew prefix that another project user can
write to (SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another.)? Compare a prefix owned by a dedicated
user that wb-guestd drives with per-user prefixes. Measure bottle
availability and install time for both. I31I31 (closed): X20-shared-homebrew: Homebrew with more than one project userX20-shared-homebrew (added to S11-verification-and-spikes in #14) adds: check version
conflicts between projects, what a project user can and can’t change,
and whether the agent may run brew install itself. In the I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3.
decision, the shared prefix belongs to a toolchain user that isn’t an
admin and has neither a password nor a shell. Only wb-guestd uses
it, through sudo -u, and project users may only read and execute
the prefix.
Answer
Section titled “Answer”Yes, with conditions. The shared prefix owned by the toolchain user
works, and a project user can’t change it. A prefix in each project
user’s home doesn’t work in practice: Homebrew builds about a sixth of
a typical Brewfile’s formulae from source there, and with LLVM among
them the install was still running after 51 minutes. A per-user prefix
at a path no longer than /opt/homebrew pours every bottle.
- The toolchain user can own and run Homebrew: yes. Root created
_wbtool(uid 440, its own group, no shell, password*, hidden, in no admin group) and/opt/homebrewowned by it. Homebrew’s own installer, run as_wbtoolthroughsudo -uwith a clean environment andNONINTERACTIVE=1, installed Homebrew 7.0.8 without asking forsudo, because the prefix already existed and belonged to it. Every file in the prefix belongs to_wbtooland its own group, which has no other members because root created it fresh for_wbtool. The installer made some folders writable by that group (drwxrwxr-x), none is writable by others, and none is set-user-ID. - A project user can’t change the shared prefix: verified. As a
standard project user, every write was refused: replacing the
bin/gitlink, a new file inbin, a new directory inCellar, editing Homebrew’s Ruby, writing toetc,var,lib/node_modulesand Python’ssite-packages, andchmodofbin(probe-shared.sh).brew uninstall,brew linkandbrew updatefailed on permissions. The first probe’s append to thegitbinary and itsbrew installwere broken (a glob that didn’t expand, and a formula that was already installed), soprobe-shared-2.shrepeated them: appending toCellar/git/2.56.0/bin/gitwas refused, andbrew install treefailed on permissions and left noCellar/tree.sudo -n -u _wbtoolwas refused because it needed a password, andsufailed. That rules out a rule without a password. The 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… checksudo -l -Ucovers the project user’s other sudoers rules. The toolchain user’s home was unreadable. - The agent can’t install packages there, and installs into its home
instead: verified.
brew installandnpm install -gfail for a project user.pip installfalls back to the user’s ownsite-packages(and refuses without--break-system-packages, as PEP 668 says),npmwithNPM_CONFIG_PREFIXin the home works, and so douv tool install,go install, andinitdbof a PostgreSQL data directory in the home. - A Brewfile runs code as the toolchain user: yes. A Brewfile with
one
systemline and onebrew "jq"line, run withbrew bundle install, created/opt/homebrew/bin/x20-from-brewfile, owned by_wbtool. So a project that writes its own Brewfile can plant a file in every project’sPATH. Homebrew 7 refused a formula file passed by path, pointed tobrew tap-new, and the code in the file didn’t run. A tap’s formulae are Ruby too, so a third-party tap would also run as the toolchain user.brew install --formula jq tree, with names only, pouredtreeand ran nothing else. - Version conflicts: versioned formulae live side by side, and real
conflicts are refused. Project B’s
node@22,python@3.12,postgresql@16andgo@1.25installed next to project A’snode,python@3.13,postgresql@17andgo, unlinked or keg-only, and each ran at its own version fromopt/<formula>/bin(andpython@3.12’slibexec/binforpython3). Which version an unversioned name runs depends on every project, though:python3in the sharedbinwas 3.14, which project A pulled in as a dependency ofawscli, although A declaredpython@3.13. Project C’smysqlwas refused, because B’smariadbinstalls the same binaries (“Cannot install mysql because conflicting formulae are installed”), andbrew bundleexited 1. - A prefix in the project user’s home: no. In
~/homebrew(/Users/wbp-b/homebrew, 21 characters), Homebrew 7 builds a formula from source when its bottle names/opt/homebrewand the prefix is longer than 13 characters. Of project A’s 59 formulae, 9 have such bottles (gettext,git,krb5,node,openssl@3,pkgconf,postgresql@17,python@3.13,python@3.14).nodeneedsrustto build, andrustneedsllvm, whose bottle is the same kind, so LLVM is built too. Homebrew also printed that this prefix is “not a Tier 1 configuration” and not to report issues. 51 minutes (3161 s) into thebrew bundlerun, the spike stopped the build, with 5 formulae built and LLVM at step 2963 of 9131. - A per-user prefix at a short path: yes. In
/opt/wbp-c(10 characters), created by root and given to the project user, all 59 formulae poured from bottles in 230 s, and none was built. The relocated tools worked:gitcloned over HTTPS, Python built a C extension from source in a virtual environment against its relocated headers, andpsqlandnoderan. Butpkgconf --cflags --libs opensslfound noopenssl, and so a C program against OpenSSL didn’t compile. The cause is thatopenssl@3is keg-only, so itsopenssl.pcis only inopt/openssl@3/lib/pkgconfig, offpkgconf’s search path. The shared prefix is the same, andpkgconf’s search path was relocated correctly (/opt/wbp-c/lib/pkgconfigfirst). Homebrew failed to sign 8 static archives (.afiles) and carried on, and 15 files outside the install receipts still name/opt/homebrew(documentation, andpython@3.14’s build settings,uvwasi.pcandpcre2-config). A symbolic link/opt/wbp-dto a directory in the home doesn’t help: Homebrew followed it, saw a 16-character prefix, and started building from source.
The conditions of the shared prefix (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Toolchain prefix”). The first three are the integrity control. The others keep sessions reproducible.
- Only the toolchain user writes the prefix, and its group is its own, with no other members. Project users and the agent have read and execute only (answers 1 to 3).
- The manifest is data.
wb-hostdreads it asbrew "<name>"lines, with names that match^[a-z0-9][a-z0-9+._@-]*$, don’t end in.rb, and fit length and count caps. It refuses anything else, a tap, a cask, options,system, a name with a/or a leading-, and logs the line and the rule.wb-guestdchecks the names again, resolves their runtime closure, and runsbrew install --formula --force-bottle -- <closure>by argument list, withHOMEBREW_FORBID_PACKAGES_FROM_PATHS=1. Neither runsbrew bundleor hands Homebrew a file a project wrote (answer 4). Formulae come fromhomebrew/coreonly, because a tap is code that would run as the toolchain user. Trustinghomebrew/corewith every project’s tools is T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix").. - Bottles only. A formula in the closure with no bottle for the
guest refuses the session before anything is installed, and nothing
is built from source (answer 6). A missing or empty formula data
snapshot refuses the reconcile, any nonzero exit of
brewrefuses the session, and the reconcile’s process group is killed at the start deadline. - A reconcile only adds (untested, I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user.).
HOMEBREW_NO_INSTALL_UPGRADEand--force-bottlecover only the formulae on the command line, and Homebrew still upgrades an outdated dependency, sowb-guestdnames the whole closure. The control is the formula API snapshot in the toolchain user’s cache, written at image build and kept byHOMEBREW_NO_AUTO_UPDATE, together withHOMEBREW_NO_INSTALLED_DEPENDENTS_CHECKandHOMEBREW_NO_INSTALL_CLEANUP. Then nothing installed is outdated. - The session’s
PATHcomes from what it declared (untested, I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user.):opt/<formula>/binfor each declared formula (and Python’slibexec/bin), without the prefix’s sharedbin(answer 5). A project can add the sharedbinback, so this isn’t a control. - A conflict fails the reconcile, and
wbrefuses the session with both formula names and--isolated(answer 5). - The toolchain user’s environment is built by
wb-guestdfrom an allowlist, withHOMEBREW_TEMPandHOMEBREW_CACHEin its own home, which is mode 700 (untested, I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user.). The default temporary folder is the shared/private/tmp.
Measurements
Section titled “Measurements”Host: Apple M2, 8 cores, 16 GB, macOS 27.0.1 (26A434), no sudo. Guest:
a fresh APFS clone of the X17-image-buildX17-image-build: Unattended image buildCan a macOS guest installed from an Apple restore image get past Setup Assistant, with wb-guestd running as a root LaunchDaemon, without SSH, scripted clicks, or MDM? spike’s sealed bundle
(macOS 27.0.1, 4 vCPU, 4 GiB, 64 GiB sparse disk), on Apple’s NAT
network, with the Xcode command line tools installed first as I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image.
puts them in the base image. Homebrew 7.0.8 from its installer in the
shared prefix, and a clone at 7.0.8-50-g8d49321 in the per-user
prefixes. Bottle tag
arm64_golden_gate. Project A is a realistic polyglot Brewfile:
git, gh, jq, ripgrep, fd, node, python@3.13, uv, go,
mise, cmake, pkgconf, postgresql@17, redis and awscli,
59 formulae with their dependencies. Each run downloaded every bottle
afresh into its own cache.
| Step | Time | Disk |
|---|---|---|
| Xcode command line tools from Apple, as root | 189 s | 1.3 GB |
| Homebrew installer as the toolchain user | 35.4 s | |
| Shared prefix, project A (59 formulae, all poured) | 179 s | 1.4 GB, cache 436 MB |
| Shared prefix, project B after A (5 formulae, 13 new kegs) | 66 s | 2.2 GB with A |
Shared prefix, project C (mysql, conflicts) |
refused in 13 s | |
| Shared prefix, project A again, nothing to install | 0.42 to 0.83 s | |
| Home prefix, project A | stopped at 51 min, unfinished | 2.1 GB so far |
Short prefix /opt/wbp-c, project A (all poured) |
230 s | 1.7 GB, cache 438 MB |
- Source builds in the home prefix, from Homebrew’s log folders in
the guest:
pkgconf13 s,git44 s,openssl@33 min 45 s,python@3.145 min 26 s,gettextabout 7 min including its downloads, and LLVM 31 min to step 2963 of 9131. At that rate LLVM alone takes about 1 h 35 min, beforerust,node,python@3.13,krb5andpostgresql@17. - Bottles by kind, from Homebrew’s formula API for project A’s 59
formulae: 43 relocatable (
:any), 7 that pour anywhere unchanged (:any_skip_relocation), and 9 built for/opt/homebrewonly. - Prefix size: the shared prefix holds 2.9 GB after projects A
and B and
tree, all owned by the toolchain user.
What was not measured
Section titled “What was not measured”- The egress gateway. The guest had a NAT network. Bottles come from
ghcr.io, which X22-no-guest-credentialsX22-no-guest-credentials: Clients without guest credentialsWhich common clients (Homebrew against ghcr.io, git, gh, npm, pip, uv, SwiftPM, Go, cargo, Claude Code) break when wb-proxyd removes every guest-supplied Authorization header and cookie on inspected hosts? and S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. already cover. - A reconcile while another project’s session runs (condition 4), and whether the pinned formula data keeps Homebrew from upgrading shared dependencies. I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user. measures it.
- A session
PATHwithout the prefix’s sharedbin(condition 5). Tools that look up a dependency’s command by name may need it. I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user.. - Homebrew’s temporary and cache folders in the toolchain user’s home (condition 7). I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user..
- The closure from
brew deps --formula -n --union,--force-bottle,--before the names,HOMEBREW_FORBID_PACKAGES_FROM_PATHS, and a missing formula data snapshot with Homebrew 7. The spike ranbrew install --formulawith names only. The bottle check before the install iswb-guestd’s own, so it doesn’t rest on how Homebrew treats--force-bottle, which doesn’t reach dependencies. I180I180 (open): X20-shared-homebrew: verify the untested toolchain prefix conditions in a guestX20-shared-homebrew (#31, PR #178) answered "yes, with conditions" for one Homebrew prefix owned by the toolchain user.. - The full source build in the home prefix. The spike stopped it to keep the host’s disk free.
- Derived images. I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. builds images from recipes as the toolchain user. The spike installed into a running guest.
What it means for the specs
Section titled “What it means for the specs”- 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., “Images”: a new “Toolchain prefix” item with
the conditions, and the project layer installed by
wb-guestdas the toolchain user (changed in this pull request). The base image, the org layer, and sealing stay as they are, because I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. and I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3. rewrite them. The sealing scan has to accept the toolchain user and its prefix: I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3. decided the scan checks kept users by name, and I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. lists the toolchain user’s areas. - 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 manifest parser and the name check in the fuzz list, conformance checks that a project user can’t write the prefix or install, that a manifest with anything but formula names is refused, and the untested conditions, and 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)? in the list of answered spikes (changed in this pull request).
- T00-indexT00-indexboundary 6 is the host terminal stream.: T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain
prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix")., projects in one guest share the
toolchain prefix and trust
homebrew/corewith each other’s tools (added in this pull request). - FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode). and FR07-toolchain-manifestFR07-toolchain-manifest: Declared toolchainA project's toolchain is declared host-side (on macOS guests, a Brewfile) and reconciled automatically before a session starts. still say Homebrew
and Brewfile. I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. rewords them to the guest’s package manager. The
manifest keeps the Brewfile’s
brew "<name>"lines, so a simple Brewfile is still a valid manifest.
Spike code
Section titled “Spike code”Branch spike/x20-shared-homebrew, at
bff92f2:
the X17-image-buildX17-image-build: Unattended image buildCan a macOS guest installed from an Apple restore image get past Setup Assistant, with wb-guestd running as a root LaunchDaemon, without SSH, scripted clicks, or MDM? wb-vmd stand-in with a relay mode, the request client, the
bottle-kind script over Homebrew’s formula API, a Brewfile for each test project, the
guest scripts, and the raw results in results/. The spike’s bundle is
a spike artifact, and no product image may descend from it.
Status: Answered 2026-10-07: yes, with conditions