Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the macOS sandbox stricter to workaround a macOS bug (fixes #4389) #4797

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kit-ty-kate
Copy link
Member

This is an attempt at fixing #4389
I've used dtrace on /usr/bin/security but 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@e3eceea

Several 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/security won't try to write in it and still succeeds.
This is most likely a bug in macOS itself but there we are!

cc @hannesm

@kit-ty-kate kit-ty-kate changed the title Relax the macOS sandbox (fixes #4389) Make the macOS sandbox stricter to workaround a macOS bug (fixes #4389) Aug 12, 2021
@kit-ty-kate kit-ty-kate linked an issue Aug 12, 2021 that may be closed by this pull request
@rjbou rjbou requested a review from AltGr August 23, 2021 16:06
@rjbou rjbou force-pushed the relax-sandbox-macos branch from 865f183 to 416a74e Compare September 2, 2021 14:49
@rjbou rjbou added this to the 2.2.0~alpha milestone Sep 2, 2021
@dra27
Copy link
Member

dra27 commented Sep 3, 2021

What's up with the macOS test?

@rjbou rjbou force-pushed the relax-sandbox-macos branch from 416a74e to 6d4a26b Compare September 13, 2021 15:58
@kit-ty-kate
Copy link
Member Author

kit-ty-kate commented Sep 13, 2021

I've sent a bug report to Apple about it btw.

@rjbou
Copy link
Collaborator

rjbou commented Sep 15, 2021

What's up with the macOS test?

Found it!

+ ${BASEDIR}/OPAM/opam-init/hooks/sandbox.sh "build" "sh" "-c" "echo SUCCESS | tee check-write"
- shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
- SUCCESS

@rjbou
Copy link
Collaborator

rjbou commented Sep 15, 2021

So sandbox check is failing, and it is removed from config file.

@rjbou rjbou force-pushed the relax-sandbox-macos branch from 6d4a26b to c9bf16b Compare May 20, 2022 08:02
@rjbou
Copy link
Collaborator

rjbou commented May 20, 2022

From tests, seems that this changes disable sandbox.

@kit-ty-kate kit-ty-kate removed this from the 2.2.0~alpha milestone Oct 31, 2022
@kit-ty-kate kit-ty-kate marked this pull request as draft July 10, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sandbox too strict on macos
4 participants