So I'm aware that Apple can designate a folder as a "data vault", and access to that folder is limited to applications that have a specific entitlement. I was wondering if there was an equivalent (or the same, I'm not fussy :) feature available to third parties, even if only during the app-store submission ?
To avoid the X-Y problem, what I want to do is have a launch agent with access to a SQLite database, and I want only that launch agent to have access. Any reads of the database will have to be done through an XPC call from the main user-facing application.
I want to store private data into that database, and I don't want there to be any way for any other application to read it. If there's a way to do that without data-vaults I'm all ears :)
I'm not sure if this is really the right place, perhaps the core-os forum would be better, but since the Apple solution is gate-kept by entitlements, I thought I'd start here :)
There are two options available to third-party developers here:
- Sandboxed app containers — These are protected as of macOS 14.
- App group containers — These are protected as of macOS 15.
I have links to the WWDC sessions that introduce these protections in Trusted Execution Resources.
Neither of these is as tightly locked down as you’d like, but such is the nature of security trade-offs. And many of the MAC protected directories for Apple products, like ~/Library/Mail, have similar trade-offs, with ways around the protection like Full Disk Access or the Finder. And this is the Mac, so if the user turns off SIP then all bets are off.
IMPORTANT If you do anything with app groups on the Mac, see App Groups: macOS vs iOS: Working Towards Harmony.
where do you keep the master encryption key
My standard answer to that is the data protection keychain. That’s protected by the Mac’s code signing infrastructure. That’s pretty reasonable protection (as long as SIP is enabled).
If the data is particularly valuable, I think it makes sense to apply both of these protections, that is, use either app or group container protections and encryption with a key stored in the data protection keychain.
I tried and failed to get XPC working with a sandboxed launch agent.
Interesting. That works for me. Historically, there were only two key issues:
- The name of the XPC endpoint must be prefixed by an app group ID.
- The agent needs a bundle ID, which you could supply via an
Info.plistembedded in the executable.
Nowadays I recommend that you not do the latter, but instead embed the launchd agent’s executable in an app-like wrapper. That gives you a place to store a provisioning profile, which is important if you want to work with app groups. Signing a daemon with a restricted entitlement explains how to set this up, albeit for a daemon not an agent.
This works best if you use SMAppService to enable your agent, which allows the system to run your agent directly from your app’s bundle.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"