Entitlements and the Hardened Runtime on macOS
Where entitlements live in a Mach-O, how the hardened runtime and its exceptions work, and which entitlements deserve a second look in triage.
TL;DR. Entitlements are key-value pairs stored inside the code signature. They switch protections off (the hardened runtime's exceptions), declare which protected resources the program may ask for (camera, microphone, Apple Events), and unlock private system features. Because they are signed, swapping them breaks the signature. Because the signer writes them, they are a statement of intent: an entitlement that opens the process to debuggers or foreign libraries is worth a question in triage, whoever signed it.
Where entitlements live
Entitlements are an XML property list in special slot 5 of the code signature. Since 2021, codesign also writes a DER-encoded copy in slot 7, which iOS 15 and later require. The CodeDirectory stores the hash of both copies, so editing either one after signing invalidates the signature. Mach-O Parser reads both, and reports any copy that doesn't match its slot (see what you can verify offline).
An app bundle may also contain Contents/embedded.provisionprofile. That is an Apple-signed profile listing the restricted entitlements a given developer may use. It sits next to the Mach-O, not inside it.
The hardened runtime
The hardened runtime is opt-in: codesign -o runtime sets the runtime flag (0x10000) in the CodeDirectory. Notarization has required it since early 2020, so almost every Developer ID app has it. Once it is on, macOS enforces a set of protections, and each one has a matching exception entitlement:
| Protection | Exception entitlement | What the exception allows |
|---|---|---|
| No unsigned executable memory | com.apple.security.cs.allow-jit | Memory mapped with MAP_JIT, for JavaScript engines |
com.apple.security.cs.allow-unsigned-executable-memory | Any writable-then-executable memory | |
com.apple.security.cs.disable-executable-page-protection | No code-signing checks on executable pages at all | |
| Library validation | com.apple.security.cs.disable-library-validation | Loading libraries signed by anyone, or not signed |
| DYLD environment variables ignored | com.apple.security.cs.allow-dyld-environment-variables | DYLD_INSERT_LIBRARIES and friends work again |
| Debugging blocked | com.apple.security.get-task-allow | Other processes may get the task port |
com.apple.security.cs.debugger | This program may debug others | |
| Protected resources | com.apple.security.device.camera, …audio-input, …personal-information.location, …automation.apple-events… | The program may ask for that resource. The user still gets the privacy (TCC) prompt |
Library validation means the process only loads libraries signed by Apple or with the same Team ID as itself. It is the main defence against dylib hijacking. An app that switches it off can have someone else's code loaded into it. It is common in apps that load third-party plug-ins, and it is also exactly what an attacker looks for.
Entitlements worth a second look
Mach-O Parser flags these and explains each one:
| Entitlement | Level | Why |
|---|---|---|
com.apple.security.get-task-allow | medium | Opens the process to debuggers and memory injection; notarization rejects it |
com.apple.security.cs.disable-library-validation | medium | Foreign libraries can be loaded into the process |
com.apple.security.cs.allow-dyld-environment-variables | medium | DYLD_INSERT_LIBRARIES injection works again |
com.apple.security.cs.disable-executable-page-protection | medium | The strongest code-signing exception there is |
com.apple.security.cs.debugger | medium | The program can attach to other processes |
com.apple.security.cs.allow-unsigned-executable-memory | low | Usual for runtimes with a JIT, also handy for shellcode |
com.apple.private.*, com.apple.rootless.* | high (unless Apple-signed) | Private, SIP-related keys honoured only for Apple's code |
| Device, personal-information and Apple Events keys | low | The program intends to ask for camera, microphone, location or automation access |
Context decides how much each matters. A web browser asking for the camera, microphone and location is ordinary: Chrome's entitlements list all three. A "PDF converter" asking for the microphone and Apple Events is not.
Restricted entitlements
Some entitlements are honoured only when Apple vouches for them. iCloud containers, many com.apple.developer.* keys and every com.apple.private.* key fall in this group. For a third-party binary, a restricted entitlement must be listed in a provisioning profile Apple signed for that Team ID. Otherwise the kernel's code-signing enforcement (AMFI) refuses to launch the program. Private entitlements are never granted to third parties.
So a non-Apple binary claiming com.apple.private.tcc.allow or a com.apple.rootless.* key means one of two things. Either someone copied entitlements from a system binary without understanding them, or the binary was meant for a machine whose protections were turned off (SIP disabled, AMFI weakened). Both are worth noting.
Without the hardened runtime
An exception entitlement only matters when the protection it relaxes is on. Without the hardened runtime, disable-library-validation and allow-dyld-environment-variables have nothing to relax: the binary already accepts foreign libraries and DYLD_ variables. Finding them anyway, on an ad-hoc-signed tool, usually means boilerplate copied from somewhere else. It still tells you what the author had in mind.
The updater sample behind the Try a sample button shows the pattern:
- It is ad-hoc signed, with no hardened runtime.
- Its signing identifier claims to be
com.apple.softwareupdate.agent. Nothing checks the identifier of an ad-hoc signature. - It asks for
get-task-allow,disable-library-validation,allow-dyld-environment-variablesandautomation.apple-events.
The program itself only prints a greeting, but the combination reads like an infostealer's.
The App Sandbox
com.apple.security.app-sandbox confines a program to its container. Further keys open specific doors: network client or server, user-selected files, downloads, printing. Mac App Store apps must be sandboxed, while Developer ID apps rarely are. Malware is almost never sandboxed, so the absence of the sandbox says little. Its presence says a lot about what the program cannot do.
Reading entitlements in an investigation
- Check the signature first. Entitlements in a signature that no longer matches the file are not granted. macOS treats the file as invalidly signed, and on Apple Silicon such code does not run at all.
- Note the hardened runtime. Without it, the exceptions are moot and the process is open by default.
- Look for injection openings:
get-task-allow,disable-library-validation,allow-dyld-environment-variables. Then check whether the binary also has a weak or@rpathlibrary that could be planted. - Compare the declared resources with the program's purpose. A browser using the camera is normal; a font manager using the microphone is not.
- Treat private keys on a non-Apple binary as high priority.
Entitlements describe what a program may do. What it is built to do is in its imports, strings and code: see capabilities and stack strings in Mac malware.
Frequently asked questions
Can a binary give itself any entitlement?
It can claim any entitlement, since whoever signs the file writes the list. Whether macOS honours it is another matter. Hardened-runtime exceptions and the App Sandbox keys need nobody's permission. Restricted entitlements must be backed by an Apple-signed provisioning profile or by Apple's own signature, and a binary that claims them without one is refused at launch.
Why does com.apple.security.get-task-allow matter?
It lets other processes of the same user obtain the program's task port, the handle a debugger uses to read and write its memory and threads. Xcode adds it to debug builds, and notarization rejects it. In a distributed binary it is either a debug build shipped by mistake or a deliberate opening for code injection.
How do I list a binary's entitlements?
On a Mac, codesign -d --entitlements - --xml /path/to/binary prints them. On any system, Mach-O Parser shows them in the Entitlements tab, for every slice of a universal binary, from both the XML and the DER copies.