fix(sandbox): confine child file reads - #841
Open
rustytrees wants to merge 2 commits into
Open
Conversation
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.
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.
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.
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
fontconfigalso need the standard system and per-user font directories during post-install. Those directories receive narrow read grants; the rest ofHOMEremains 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
HOMEinto 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 passedzig build test: 5,062 passed, 3 skipped; exit code 0zig build: 8 of 8 steps succeededzig fmt --checkon all changed Zig filesgit verify-commit HEAD