Hardened Runtime is a code-signing option in macOS that tells the kernel to apply a set of runtime protections to a process, blocking techniques such as code injection, dynamic library hijacking and process memory tampering unless the developer explicitly declares an exception. It is one of the layered defenses in macOS security & privacy, and since macOS Mojave 10.14.5 it has been a mandatory requirement for app notarization.
Unlike a sandbox, which limits what an app may access, the Hardened Runtime limits how the running app itself can be modified. It protects the integrity of a signed program after launch, so that an attacker cannot quietly turn a trusted application into a carrier for malicious code.
How the Hardened Runtime protects a process
The protection is activated by a flag in the code signature, set with the --options runtime argument to codesign or by the corresponding setting in Xcode. When the kernel launches a binary carrying this flag, it enforces stricter code-signing rules for the whole lifetime of the process.
In practice, the kernel refuses to map memory pages that are both writable and executable, rejects libraries that are not signed by Apple or the same team, ignores environment variables such as DYLD_INSERT_LIBRARIES that would preload foreign code, and denies debugger attachment through the task_for_pid interface. Each of these closes a route that malware and cheating tools have traditionally used to alter a legitimate program.
The runtime also gates access to sensitive resources. A hardened app that wants the camera, microphone, location, contacts or Apple Events automation must declare a matching resource-access entitlement; without it, the request fails even before the TCC privacy prompt appears.
Hardened Runtime entitlements and exceptions
Some legitimate software needs behavior that the runtime blocks by default, so Apple defines exception entitlements that relax individual protections. The table lists the most important ones and the security cost of enabling each.
| Entitlement | What it allows | Typical legitimate user | Risk level |
|---|---|---|---|
| allow-jit | Memory mapped with the MAP_JIT flag | Browsers and JavaScript engines | Moderate |
| allow-unsigned-executable-memory | Writable and executable memory without MAP_JIT | Older runtimes and emulators | High |
| allow-dyld-environment-variables | DYLD variables that alter library loading | Developer tools | High |
| disable-library-validation | Loading plug-ins signed by other teams | Audio hosts and creative suites | High |
| disable-executable-page-protection | Modification of executable code pages | Rare legacy software | Very high |
| debugger | Attaching to other processes as a debugger | Debuggers and profilers | High |
These keys live under the com.apple.security.cs prefix. Each exception should be justified by a concrete requirement, because every one widens the attack surface that the runtime was designed to remove. Notarization accepts them, but security reviewers treat a long exception list as a red flag.
Resource access under the Hardened Runtime
Resource-access entitlements are declarations of intent, not grants. They allow a hardened app to request a protected resource, after which macOS still asks the user for consent through the TCC framework.
| Resource | Entitlement key suffix | Missing entitlement result |
|---|---|---|
| Camera | device.camera | Capture session fails silently |
| Microphone | device.audio-input | Audio input returns no data |
| Location | personal-information.location | Location services denied |
| Contacts and calendars | personal-information.addressbook, calendars | Database access refused |
| Apple Events | automation.apple-events | Scripting of other apps fails |
The two-step model provides defense in depth: a compromised hardened app without the camera entitlement cannot even trigger a consent dialog, so an attacker cannot trick the user into approving access the developer never intended.
Hardened Runtime compared with related macOS protections
The Hardened Runtime is one layer among several, and it is often confused with neighboring mechanisms. The comparison clarifies what each one protects.
| Mechanism | What it protects | When it acts | Who enables it |
|---|---|---|---|
| Hardened Runtime | Integrity of a running app | Throughout execution | Developer via signature flag |
| App Sandbox | User data and system resources | Throughout execution | Developer via entitlement |
| App notarization | Distribution of known-clean software | Before first launch | Developer submits to Apple |
| Gatekeeper | Launch of unverified downloads | At first launch | macOS by default |
| SIP | System files and Apple processes | Always | macOS by default |
The key distinction is that SIP protects the operating system, while the Hardened Runtime extends similar integrity rules to third-party applications. Mac App Store apps must use the App Sandbox; apps distributed outside the store with Developer ID must use the Hardened Runtime to be notarized, and many use both.
Enabling and verifying the Hardened Runtime
Developers enable the feature by adding the Hardened Runtime capability in Xcode or by signing on the command line with codesign --options runtime --entitlements app.entitlements. All nested binaries, frameworks and helper tools must be signed with the same flag, or notarization rejects the bundle.
Verification is straightforward: codesign -dv --verbose=4 MyApp.app prints a flags line that includes runtime when the option is active, and codesign -d --entitlements - MyApp.app lists the declared exceptions. Administrators can run the same commands to audit installed software before approving it for a managed fleet.
Common mistakes and limitations
Adopting the runtime exposes hidden dependencies, and most failures follow recognizable patterns that the table below links to their causes.
| Symptom | Cause | Fix |
|---|---|---|
| Plug-ins fail to load | Library validation rejects foreign signatures | Add disable-library-validation only if required |
| JIT engine crashes on launch | Writable executable memory denied | Use MAP_JIT with allow-jit |
| Notarization rejected | Nested helper lacks runtime flag | Re-sign every nested binary |
| Microphone always silent | Missing audio-input entitlement | Declare the entitlement and re-sign |
The runtime has clear limits. It does not restrict file or network access, which is the role of the App Sandbox, and it cannot stop malicious behavior that the developer deliberately built in. It also offers no protection against an attacker who already holds root privileges and can disable protections system-wide.
The simple explanation
Think of a signed app as a sealed machine. It left the factory in a known state. The Hardened Runtime keeps the seal intact while the machine runs. Nobody can slip extra parts inside or rewire it on the fly.
Sometimes an app needs to do something unusual. It may use the microphone or load add-ons from other companies. The developer must then say so in advance. The main idea is simple: a trusted app stays trusted after it starts, not only at installation.
How it is used in practice
A small company builds a podcast recording app for macOS and distributes it from its own website. To pass notarization, the release engineer enables the Hardened Runtime in Xcode. The first test build records only silence, because the app lacks the audio-input entitlement; adding that single key and re-signing fixes the problem.
The app also hosts third-party audio effect plug-ins, which the runtime initially refuses to load because they carry other developers’ signatures. After weighing the risk, the team adds disable-library-validation but no other exceptions, documents the reason and verifies the signature with codesign -dv. The notarized build installs without Gatekeeper warnings, and the product keeps every other runtime protection fully active.