Allow the macOS sandbox to write in the /var/folders/ and /var/db/mds/ directories#4797
Merged
kit-ty-kate merged 1 commit intoocaml:masterfrom Nov 4, 2025
Merged
Conversation
111e564 to
865f183
Compare
AltGr
approved these changes
Sep 2, 2021
865f183 to
416a74e
Compare
Member
|
What's up with the macOS test? |
416a74e to
6d4a26b
Compare
Member
Author
|
I've sent a bug report to Apple about it btw. |
Collaborator
Found it! |
Collaborator
|
So sandbox check is failing, and it is removed from config file. |
6d4a26b to
c9bf16b
Compare
Collaborator
|
From tests, seems that this changes disable sandbox. |
Member
Author
|
|
…mds/` directories It is required by some of macOS core tools such as security(1) and previous TMPDIR stored in /var/folders/*/*/T/ have been seen accessed by xcode in the wild on occasion. While the /var/folders/*/*/C/ directory contain things that are kept indefinitely, these files are in theory understood by applications to be writeable by anyone and thus not trusted. The mds subdirectory is a cache used to search for files in the system. Both of these are part of other tools that use sandbox-exec such as MacPorts. See for example: https://github.com/macports/macports-base/blob/2c6fc24ddd1d6961afa83c5b35be12224b6850f6/src/port1.0/portsandbox.tcl#L92
/var/folders/ and /var/db/mds/ directories
c9bf16b to
c1f6c5b
Compare
Member
Author
|
Coping the new commit description: |
rjbou
approved these changes
Nov 4, 2025
Collaborator
rjbou
left a comment
There was a problem hiding this comment.
Discussed on dev meeting: The PR is good to go.
Collaborator
|
ocaml-benchmarks is failing with no log, it's out of the scope of this PR. |
Member
Author
|
The ocaml-benchmark failure comes from ocaml/infrastructure#179. Ignoring. |
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.
This is an attempt at fixing #4389
Fixes discuss.ocaml.org#17407
I've used
dtraceon/usr/bin/securitybut I still can't find the exact point where something is written in that directory.It looks related to something in
/private/var/db/mds, probably a symlink to/private/var/folders.In any case i've looked around and realized that macports had similar things so maybe it makes sense(?). They also have other things but I'm not sure we should allow even more: https://github.com/macports/macports-base/blob/2c6fc24ddd1d6961afa83c5b35be12224b6850f6/src/port1.0/portsandbox.tcl#L92
All in all I have no idea what this directory is supposed to be in the context of
/usr/bin/security. Their commit adding it doesn't say anything either: macports/macports-base@e3eceeaSeveral blog posts in the wild are also trying to understand what's up with this directory:
hier(7)says it's "per-user temporary files and caches", so allowing writes like macports does doesn't seem right to me.However, I found out (late into writing this PR even ^^") that if we forbid reads into that directory,
/usr/bin/securitywon't try to write in it and still succeeds.This is most likely a bug in macOS itself but there we are!
cc @hannesm
Backported to the 2.5 branch in #6775