It drives me nuts that sandbox-exec has "sandbox" in the name, since it's nothing like a real sandbox, and much closer to something like a high-level seccomp, and not much to do with "App Sandboxes" which is a distinct macOS feature. IMO a real sandbox let's a program act how it wishes without impacting anything outside the sandbox. In reality many of these tools just cause hard failures when attempting to cross the…
> not much to do with "App Sandboxes" which is a distinct macOS feature The App Sandbox is literally Seatbelt + Cocoa "containers". secinitd translates App Sandbox entitlements into a Seatbelt profile and that is then transferred back to your process via XPC and applied by an libsystem_secinit initializer early in the process initialization, shortly before main(). This is why App Sandbox programs will crash with `for…
An example from /System/Library/Sandbox/Profiles/application.sb, the profile that is used for App Sandboxed applications, on my system:
(when (entitlement "com.apple.security.files.downloads.read-only")
(read-only-and-issue-extensions (home-subpath "/Downloads")))
(when (entitlement "com.apple.security.files.downloads.read-write")
(read-write-and-issue-extensions (home-subpath "/Downloads")))
(when (or (entitlement "com.apple.security.files.downloads.read-only")
(entitlement "com.apple.security.files.downloads.read-write"))
(allow process-exec (home-subpath "/Downloads")))