Can macOS verify a worker’s effective sandbox policy before it runs?

I’m building a local app on an Apple silicon Mac. Before a worker or any of its child processes can run, I need to verify the worker’s effective filesystem and network restrictions, including inherited restrictions. I need to allow that same pending launch only if the policy matches, and deny it if verification fails or times out.

I reviewed Apple’s App Sandbox guidance and the Endpoint Security documentation for exec authorization and entitlement metadata. I haven’t found documentation showing that these expose the complete effective policy for the pending launch.

Is there a supported public macOS API that provides this guarantee? If so, which API and macOS versions support it? If not, is this outside what the public APIs can verify?

Answered by DTS Engineer in 917624022
Written by BoneBuildsLab in 858464021

Is there a supported public macOS API that provides this guarantee? If so, which API and macOS versions support it?

Not really. There are three supported way to limit the capabilities of a program:

  • App Sandbox inheritance
  • A new App Sandbox
  • Endpoint Security

I’ll consider these in reverse order…

Endpoint Security is fully dynamic. As the ES client, you get to authorise each operation done by the targeted process. There’s no way to preflight that. Rather, the behaviour you get depends on what operations are done by the child process and how you respond to them.

For a new App Sandbox, you can inspect the entitlements of the target executable but that has limitations:

  • The App Sandbox entitlements are very coarse grained.
  • There’s an obvious TOC/TOU problem.

Of course, the latter is fundamental to any preflight system.

For App Sandbox inheritance, the target process inherits your processes restrictions. There’s no way to inspect those as an in-memory thing. You can inspect your own executable’s entitlements and the entitlements of the process you plan to executable, but:

  • That has the same limitations as the new App Sandbox case discussed above.
  • Inspecting your own entitlements is pretty pointless because those are baked into your own executable.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Written by BoneBuildsLab in 858464021

Is there a supported public macOS API that provides this guarantee? If so, which API and macOS versions support it?

Not really. There are three supported way to limit the capabilities of a program:

  • App Sandbox inheritance
  • A new App Sandbox
  • Endpoint Security

I’ll consider these in reverse order…

Endpoint Security is fully dynamic. As the ES client, you get to authorise each operation done by the targeted process. There’s no way to preflight that. Rather, the behaviour you get depends on what operations are done by the child process and how you respond to them.

For a new App Sandbox, you can inspect the entitlements of the target executable but that has limitations:

  • The App Sandbox entitlements are very coarse grained.
  • There’s an obvious TOC/TOU problem.

Of course, the latter is fundamental to any preflight system.

For App Sandbox inheritance, the target process inherits your processes restrictions. There’s no way to inspect those as an in-memory thing. You can inspect your own executable’s entitlements and the entitlements of the process you plan to executable, but:

  • That has the same limitations as the new App Sandbox case discussed above.
  • Inspecting your own entitlements is pretty pointless because those are baked into your own executable.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"