Privileged helper boundary
arcbox-helper is the root-owned host service for the small set of ArcBox actions that a user-space daemon cannot perform. It exposes an authenticated local RPC boundary, applies only ArcBox-owned host changes, and leaves VM and Docker control in the user-space daemon. The application control plane calls this boundary when it must change host networking or system integration.
Boundary role
Local RPC boundary
The helper presents a Unix socket at /var/run/arcbox-helper.sock. The daemon, core route manager, and CLI use a shared client rather than calling privileged system APIs themselves. RPC requests use a local tarpc service and return structured helper errors, so callers can tell an ownership conflict from an unavailable service.
The socket is local and world-connectable by design. The socket mode only permits a process to make a connection; it does not grant permission to run a privileged operation. In a release build, the helper authenticates the connecting process before it dispatches any RPC. This keeps the privilege boundary in the helper instead of relying on a file mode that cannot identify the caller.
References: app/…/lib.rs• L45-55 app/…/client.rs• L35-69 app/…/server.rs• L75-125
Compatibility boundary
The helper has an independent version because its on-disk binary and its RPC wire contract have a longer life than one daemon build. A mutation-capable client first reads the helper version and returns no usable mutation client when the version is missing, malformed, below the required floor, or from another wire major. Diagnostics can still use the version-only probe to report why installation is needed.
RPC method and error ordering is part of the wire contract. New methods and error variants must be added at the end of their encoded lists. This prevents a daemon and an older helper from interpreting the same request as a different privileged action.
References: app/…/client.rs• L40-79 app/…/client.rs• L190-211 app/…/lib.rs• L45-55 common/…/helper.rs• L14-22 common/…/helper.rs• L66-100
Delegated host operations
Host networking operations
The helper owns host changes that connect the VM network to the host. It can add and remove the container subnet route, and it can remove a route only when the route still belongs to the expected bridge interface. The core route reconciler discovers the bridge and asks the helper to perform the mutation. Route failure is therefore a host integration failure rather than a reason to put privileged code into the VM lifecycle.
The daemon retries while launchd starts the helper or while the bridge becomes visible. A route conflict is reported without replacing an existing route, which protects a route that another service may now own. See daemon lifecycle for how route state and startup progress are reported.
References: app/…/lib.rs• L56-63 app/…/route.rs• L7-44 app/…/route_reconciler.rs• L408-461
Host integration links
The helper manages links that make ArcBox available to standard host tools. The Docker socket link exposes a selected ArcBox user socket through /var/run/docker.sock. CLI links expose the Docker tools from the app bundle through /usr/local/bin, so shells do not need an app-specific path. See API and Docker compatibility for how this socket serves Docker clients.
The daemon performs these actions as idempotent self-setup tasks. It checks the desired state first, uses one helper connection for the setup pass, and verifies required postconditions when a task is part of startup. Homebrew and app installation can prepare user-level state, but they leave root-owned CLI links to this helper.
References: app/…/lib.rs• L74-85 app/…/socket.rs• L13-53 app/…/cli.rs• L16-45 app/…/self_setup.rs• L1-10 app/…/self_setup.rs• L59-114
Managed host records
The helper also owns two small host records used by ArcBox services. It installs a marked resolver file under /etc/resolver for the ArcBox domain, and it adds a fixed 127.0.0.1 ArcBox entry to /etc/hosts so the guest-data mount can use the ArcBox:/ source name. Callers cannot provide arbitrary host entries.
Each record has a status, install, and uninstall operation. The marker identifies content that ArcBox may replace or remove. Uninstall leaves an unmarked record in place, so removing ArcBox does not erase another tool's DNS or hosts configuration.
References: app/…/lib.rs• L65-72 app/…/lib.rs• L94-104 app/…/dns.rs• L11-63 app/…/hosts.rs• L23-103
Installation and launchd
Installed service
The production helper is installed as /usr/local/libexec/arcbox-helper with root ownership. Its launchd job is /Library/LaunchDaemons/com.arcboxlabs.desktop.helper.plist, which registers the service in the system launchd domain. This is separate from the user-level launchd agent that runs arcbox-daemon.
The install command copies the helper, sets root ownership, writes the bundled launchd definition, and bootstraps it into the system domain. It requires administrator authorization because it changes root-owned files and registers a system service. The daemon service and shell setup are separate install steps, so a helper-only repair can use sudo abctl _install --no-daemon --no-shell.
References: common/…/paths.rs• L62-82 app/…/install.rs• L99-172
launchd socket activation
launchd creates the helper socket before it starts the process and passes the listening descriptor to the helper. The helper does not need to create the production socket or choose its permissions. The first client connection starts the helper, and the production --idle-exit option lets it stop after 30 seconds with no active connections. launchd can start it again on the next connection.
The launchd job gives shutdown up to 45 seconds. This is a safety margin for cleanup and does not make the helper a long-running owner of VM state; the user-space daemon remains responsible for its own lifecycle.
References: bundle/com.arcboxlabs.desktop.helper.plist• L5-28 app/…/launchd.rs• L1-55 app/…/server.rs• L23-27 app/…/server.rs• L54-73
Signing and identity
Release peer identity
Release authentication binds the live Unix peer to its macOS code signature. The helper prefers the peer audit token and falls back to the peer process ID only when the audit-token socket option is unavailable. It accepts an Apple-signed process with the ArcBox Team ID and an allow-listed ArcBox identifier for the daemon, development daemon, CLI, or desktop app.
The check runs before tarpc dispatch. A process that can open the socket but does not meet the signing requirement receives no privileged operation. The release workflow signs the helper, daemon, and CLI with Developer ID identities and verifies each artifact after signing.
References: app/…/peer_auth.rs• L1-23 app/…/peer_auth.rs• L25-95 .github/…/release.yml• L287-314
Development signing
Debug helpers skip peer signature checks to support ad-hoc local binaries. This mode is for a manually started helper and local tests only. It must not be used as the production security model.
The development daemon has its own allowed release identifier and normally uses the development entitlement set when it is signed locally. Those entitlements support local runtime needs; they do not replace helper peer authentication in a release build.
References: app/…/peer_auth.rs• L45-52 app/…/peer_auth.rs• L224-251 bundle/arcbox.dev.entitlements• L1-18 scripts/dev-daemon.sh• L45-54
Development sockets and test isolation
Socket selection
The client uses /var/run/arcbox-helper.sock unless ARCBOX_HELPER_SOCKET supplies another path. A manually started helper uses the same effective path and binds it with mode 0666, but release builds still perform peer authentication. This gives development a way to run without a system launchd registration while keeping the production path fixed.
Tests that run in parallel should pass an explicit socket to Client::connect_to. That method ignores the process-wide environment override, so one test cannot silently connect to another test's helper.
References: app/…/lib.rs• L13-21 app/…/client.rs• L54-69 app/…/server.rs• L130-158
Filesystem sandbox
Debug builds can set ARCBOX_HELPER_TEST_ROOT to move privileged destinations below a temporary directory. The real helper binary can then exercise link, resolver, hosts, and log behavior without root access or changes to the live host. Release builds ignore this variable and always resolve the real absolute paths.
The development profile also uses a separate user data tree and Docker socket target, such as ~/.arcbox-dev, but the root helper remains one shared service. The target validation keeps production and development socket paths inside their expected ArcBox data trees.
References: app/…/fs_root.rs• L1-47 app/…/mod.rs• L43-53 common/…/paths.rs• L84-92
Safety model
Input and ownership rules
The RPC handler parses every caller-controlled value before it reaches a mutation. The helper then applies ownership checks to the destination and uses markers or fixed values to decide what ArcBox may change.
| Area | Allowed change | Protected state |
|---|---|---|
| Routes | Add or remove the expected direct route | Foreign interface, gateway route, or conflicting route |
| Docker socket | Link to a validated .arcbox or .arcbox-dev socket | A real socket or a foreign symlink |
| CLI tools | Link a regular file inside an ArcBox app xbin tree | Foreign links, symlink targets, and non-ArcBox files |
| DNS resolver | Write or remove a file carrying the ArcBox marker | An unmarked resolver file |
| Hosts alias | Add or remove the one fixed marked alias | User entries and unmarked hosts lines |
These rules make cleanup conservative. If ownership is unclear, the helper reports an error or leaves the path unchanged instead of taking control of it.
References: app/…/handler.rs• L18-124 app/…/mod.rs• L1-9 app/…/cli.rs• L47-75 app/…/socket.rs• L25-54 app/…/route.rs• L24-44
Failure behavior
The helper returns structured errors for validation failures, ownership conflicts, occupied system paths, and operating-system failures. The daemon treats ordinary self-setup as best effort and logs a repair command when the helper is unavailable. Startup-critical callers can make a task fail instead. The CLI doctor path can inspect an incompatible helper without sending mutation requests.
References: app/…/error.rs• L11-72 app/…/self_setup.rs• L38-56 app/…/self_setup.rs• L68-114 app/…/doctor.rs• L485-507
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the helper package version, workspace dependency pin, and
MIN_HELPER_VERSIONaligned when a wire change or required safety fix needs a new on-disk helper. - Add RPC methods and
HelperErrorvariants only at the end of their wire-encoded order. Update every client and helper together. - Keep the release peer allow-list aligned with every signed daemon, CLI, and desktop identifier, including the development daemon identifier.
- If a privileged path or ownership rule changes, update the launchd plist, shared path constants, validators, and the debug filesystem-root behavior as one contract.
- Preserve the distinction between the system LaunchDaemon for the helper and the user LaunchAgent for the daemon. Development installs must not take over per-instance daemon or shell state.
- Keep
Client::connect_toindependent ofARCBOX_HELPER_SOCKETso parallel helper tests remain isolated.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A caller connects through the 0666 socket without an allowed release signature | The connection is dropped before any privileged RPC runs | Release peer audit-token or PID code-signature check |
| The installed helper is old, malformed, or from another wire major | Mutation setup is skipped or a required setup task fails | Version RPC before returning a mutation-capable client |
/var/run/docker.sock is a real socket or a foreign symlink | ArcBox does not replace the existing Docker integration | Destination must be an ArcBox-owned symlink |
| A resolver file lacks the ArcBox marker | ArcBox does not overwrite or remove the resolver | Marker-based managed-file ownership |
| A route changed to another interface before cleanup | Route removal is refused and the foreign route remains | route_remove_if_owned checks interface and direct-route ownership |
ARCBOX_HELPER_TEST_ROOT is used with a release helper | The override has no effect and production paths remain active | The test-root override is compiled out for release builds |
| A development test uses the shared socket environment variable | It can connect to the wrong helper instance | Use Client::connect_to with a per-test socket |
Key files
| File | Why to read it |
|---|---|
| app/…/lib.rs | Defines the RPC contract, socket default, managed hosts alias, and wire-order rules. |
| app/…/client.rs | Shows the safe client entry points and the compatibility gate. |
| app/…/server.rs | Explains socket selection, connection handling, and idle shutdown. |
| app/…/peer_auth.rs | Defines the release trust boundary for local clients. |
| app/…/handler.rs | Shows where request validation separates callers from privileged mutations. |
app/arcbox-helper/src/server/mutations/ | Groups the route, socket, CLI-link, DNS, and hosts ownership policies. |
| app/…/install.rs | Describes privileged installation and system launchd registration. |
bundle/com.arcboxlabs.desktop.helper.plist | Defines production socket activation and helper lifecycle settings. |
| common/…/helper.rs | Defines helper version compatibility and reinstall policy. |
| common/…/paths.rs | Defines the shared production paths, service labels, and profile socket ownership rules. |
| scripts/dev-daemon.sh | Describes the direct development daemon workflow and local signing context. |