Skip to content

Fix host-injected content ownership on macOS guests#156

Merged
glageju merged 4 commits into
mainfrom
fix/macOS-skills-not-readable
May 19, 2026
Merged

Fix host-injected content ownership on macOS guests#156
glageju merged 4 commits into
mainfrom
fix/macOS-skills-not-readable

Conversation

@glageju
Copy link
Copy Markdown
Contributor

@glageju glageju commented May 19, 2026

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/sandbox itself 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. MakeWritable defers a chownRecursive over /home/sandbox so injected files are readable on every return path — fast-path (already writable), overlay-mount, and tmpfs-fallback. chownRecursive skips 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

glageju and others added 4 commits May 18, 2026 21:11
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>
@glageju glageju marked this pull request as ready for review May 19, 2026 04:59
@glageju glageju requested review from JAORMX and jhrozek May 19, 2026 04:59
@glageju glageju merged commit bf997e4 into main May 19, 2026
8 checks passed
@glageju glageju deleted the fix/macOS-skills-not-readable branch May 19, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Injected host content unreadable to sandbox user on macOS (skills, settings, credentials silently invisible)

2 participants