Skip to content

fix(sandbox): confine child file reads - #841

Open
rustytrees wants to merge 2 commits into
indaco:mainfrom
rustytrees:security/sandbox-read-confinement
Open

fix(sandbox): confine child file reads#841
rustytrees wants to merge 2 commits into
indaco:mainfrom
rustytrees:security/sandbox-read-confinement

Conversation

@rustytrees

@rustytrees rustytrees commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

The macOS sandbox permits the metadata and system runtime reads needed to launch ordinary tools, but denies file contents under user, application, package-manager, device, and mutable system roots. Formula data is readable only under the current keg and Malt prefix.

Formula tools such as fontconfig also need the standard system and per-user font directories during post-install. Those directories receive narrow read grants; the rest of HOME remains inaccessible. Generated Ruby wrappers receive a literal read grant, and system Ruby starts with RubyGems disabled so it does not scan host-installed gems under /Library/Ruby.

The regression tests run real sandboxed processes. One confirms that a child cannot copy an arbitrary file from HOME into the prefix. Another confirms that an official-style post-install command can read a font from ~/Library/Fonts.

Related Issue

Closes #847.

Notes for Reviewers

The security regression failed before the original fix because the outside source was copied. A compatibility regression added during catalog testing also failed before the follow-up commit: the sandbox denied a font under ~/Library/Fonts, leaving the fast suite at 2,424 of 2,425 tests.

Verification after both fixes completed with:

  • zig build test-one: 2,425 passed
  • zig build test: 5,062 passed, 3 skipped; exit code 0
  • zig build: 8 of 8 steps succeeded
  • zig fmt --check on all changed Zig files
  • git verify-commit HEAD

Deny file contents under mutable and user-data roots while preserving the metadata and system runtime reads macOS processes need. Grant formula data and generated Ruby scripts explicitly, and start system Ruby without scanning host-installed gems.
@indaco

indaco commented Aug 13, 2026

Copy link
Copy Markdown
Owner

@rustytrees Thanks for the contribution! One small request: could you please instruct your agent to follow the PR template provided in the repository for PRs? It helps keep the PRs consistent and easier to review. Thanks!

Formula tools such as fontconfig scan system and per-user font directories during post-install. Keep those directories readable without opening the rest of HOME. Pass HOME to each sandbox profile and cover both the allowed font read and a denied sibling file.
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.

Security: sandboxed post-install commands can read arbitrary user files

2 participants