Fix host-injected content ownership on macOS guests#156
Merged
Conversation
On macOS hosts, host-side rootfs hooks cannot chown injected content (skills, settings, credentials) to UID 1000, and go-microvm's boot-time fixup short-circuits when /home/sandbox itself is already owned by the sandbox user. Files land owner-only and the agent silently sees nothing. Reconcile ownership inside the guest by recursively chowning /home/sandbox after MakeWritable runs. The walk skips entries already owned by the target uid:gid so the Linux common case incurs no overlayfs copy-up cost. Walk and per-entry chown errors are logged and the walk continues rather than aborting on the first failure. Also tightens the test for chownRecursive: the previous version was tautological (chowned to the egid that files already had); the new one pre-chowns files to a supplementary gid and asserts the walk visited every entry. Fixes #154
Strip drafting prose and alternative-comparison phrasing from MakeWritable and chownRecursive docs. Collapse the call-site comment in bbox-init to one sentence; the rationale lives on MakeWritable. Remove copy_test.go pending a coverage pass that exercises MakeWritable's deferred chown directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jhrozek
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #154. On macOS hosts, files injected from
~/.claude/etc. into the guest rootfs end up owned by the host UID with mode 0600, and the sandbox user (UID 1000) inside the VM cannot read them. Skills, settings, instructions, and seeded credentials are silently invisible to the agent.The host-side injector cannot chown to UID 1000 on macOS (EPERM for non-root), and go-microvm's boot-time fixup short-circuits when
/home/sandboxitself is already owned 1000:1000 (the OCI image default), so injected content keeps its host ownership.Fix
Reconcile ownership inside the guest, where bbox-init runs as root and can chown anything to anything.
MakeWritabledefers achownRecursiveover/home/sandboxso injected files are readable on every return path — fast-path (already writable), overlay-mount, and tmpfs-fallback.chownRecursiveskips entries already owned by the target uid:gid, keeping the Linux common case free of overlayfs copy-up. Walk and per-entry chown errors log and continue.Test plan
mkdir -p ~/.claude/skills/probe && echo SKILL > ~/.claude/skills/probe/SKILL.md, runbbox claude-code, confirm/skillslistsprobe.--seed-credentials) are readable by the sandbox user.~/.claude/settings.jsonand~/.claude/CLAUDE.mdare loaded by the agent.