Glossary
XPC
XPC is Apple's IPC framework on top of Mach messages, with launchd starting services on demand. Why connections fail and how privileged helpers get abused.
XPC is Apple's high-level IPC framework — the recommended way for one process to call another on macOS / iOS / etc. Implemented on top of Mach messages with:
- A structured codec for serializing arguments (dictionaries of primitive types, plus typed objects).
- Queue-aware dispatch — every XPC connection has an associated dispatch queue; messages arrive as block invocations on that queue.
- Launchd integration — XPC services declared in an app bundle's
Contents/XPCServices/are spawned automatically by launchd when the app first connects. - Reverse-RPC — both sides can send messages; not just request/reply.
Used everywhere:
- App ↔ helper process (Safari's renderer processes, Photos' importer, etc.).
- Apps ↔ system daemons (LaunchServices, location, contacts).
- Apps ↔ Apple-managed services (CloudKit, iCloud sync engines).
- Inside frameworks for cross-process isolation (sandboxed XPC services handle dangerous parsing tasks).
The C API is xpc_* (xpc_connection_create, xpc_dictionary_set_string, xpc_connection_send_message). The Objective-C API is NSXPCConnection (typed, protocol-based, async-await-friendly).
XPC services are also one of the few cleanly-isolated ways to crash a piece of an app — if your renderer process dies, the main app process restarts it without crashing.
When the connection breaks
Two errors show up in every XPC client sooner or later, and they mean different things. XPC_ERROR_CONNECTION_INTERRUPTED says the service process died or was killed by jetsam; the connection object is still good, launchd will start the service again on the next message, and any state you kept in the service is gone. XPC_ERROR_CONNECTION_INVALID is final: the service name was wrong, the service is not in your bundle, or the sandbox will not let you look it up. Retrying an invalid connection in a loop is a classic way to burn a core.
Why attackers read XPC services first
A privileged helper that listens on a Mach service is an open door unless it checks who is calling. The old pattern, checking the caller's PID and then looking up its code signature, is racy: the client can exec into a different binary or the PID can be reused between the check and the use. Validate the audit token instead, or on macOS 13 and later set a code signing requirement on the connection (xpc_connection_set_peer_code_signing_requirement, or setCodeSigningRequirement: on NSXPCConnection) and let the system enforce it. A long list of local privilege escalation bugs in third-party Mac helpers came down to exactly this.
See also: Mach message, launchd, and the Mach IPC internals article.