Hardened Runtime

On this page 8

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.

EntitlementWhat it allowsTypical legitimate userRisk level
allow-jitMemory mapped with the MAP_JIT flagBrowsers and JavaScript enginesModerate
allow-unsigned-executable-memoryWritable and executable memory without MAP_JITOlder runtimes and emulatorsHigh
allow-dyld-environment-variablesDYLD variables that alter library loadingDeveloper toolsHigh
disable-library-validationLoading plug-ins signed by other teamsAudio hosts and creative suitesHigh
disable-executable-page-protectionModification of executable code pagesRare legacy softwareVery high
debuggerAttaching to other processes as a debuggerDebuggers and profilersHigh
Runtime exception entitlements

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.

ResourceEntitlement key suffixMissing entitlement result
Cameradevice.cameraCapture session fails silently
Microphonedevice.audio-inputAudio input returns no data
Locationpersonal-information.locationLocation services denied
Contacts and calendarspersonal-information.addressbook, calendarsDatabase access refused
Apple Eventsautomation.apple-eventsScripting of other apps fails
Resource-access entitlements and their effect

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.

The Hardened Runtime is one layer among several, and it is often confused with neighboring mechanisms. The comparison clarifies what each one protects.

MechanismWhat it protectsWhen it actsWho enables it
Hardened RuntimeIntegrity of a running appThroughout executionDeveloper via signature flag
App SandboxUser data and system resourcesThroughout executionDeveloper via entitlement
App notarizationDistribution of known-clean softwareBefore first launchDeveloper submits to Apple
GatekeeperLaunch of unverified downloadsAt first launchmacOS by default
SIPSystem files and Apple processesAlwaysmacOS by default
Hardened Runtime and neighboring security layers

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.

SymptomCauseFix
Plug-ins fail to loadLibrary validation rejects foreign signaturesAdd disable-library-validation only if required
JIT engine crashes on launchWritable executable memory deniedUse MAP_JIT with allow-jit
Notarization rejectedNested helper lacks runtime flagRe-sign every nested binary
Microphone always silentMissing audio-input entitlementDeclare the entitlement and re-sign
Typical Hardened Runtime problems

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.