by m132 · 9mo ago · 0 comments
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 `forbidden-sandbox-reinit` in libsystem_secinit if you run them under sandbox-exec. macOS does no OS-level virtualization.
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")))