Authenticating XPC peers

Ilya Kulakov
2 min readMay 31, 2020

--

In the past few days I’ve been catching up with security in the context of XPC services. Here are my findings current as of macOS 10.15.5

Embedded XPC Services

These are services that live inside your app’s bundle and thus no extra work is needed:

an XPC service is private, and is available only to the main application that contains it.

Privileged Helper Tools using XPC

When an XPC service needs perform privileged tasks, such as updating or installing applications on user’s behalf, it should be elevated via SMJobBless.

The service will be run as root and will be available for any other process in the system.

Thus to authorize privilged operations it must authenticate its peers first. The common practice is to ensure that:

  1. Peer is code-signed by Apple
  2. Peer is code-signed by You
  3. Peer’s bundle is one of the expected
  4. Peer does not have entitlements that allow code injection

1. Peer is code-signed by Apple

If, god forbid, your signing key gets stolen you can invalidate it with Apple and prevent any future apps to be signed by both You and Apple (via Mac App Store submission or Notarization). Thus rendering it impossible for an attacker to publish a modified app in your name.

2. Peer is code-signed by You

Naturally, you don’t want any app to perform priviliged tasks through your service.

3. Peer’s bundle is one of the expected

If you have multiple apps signed using the same key you may want to limit which of them have access to your privileged service.

4. Peer does not have entitlements that allow code injection

That’s an important one. It is possible to sign your app in such a way that it allows loading of 3rd party libraries or is open to mach task injection. Thus making it possible for an attacker to communicate with the privileged service under a disguise of your app.

References

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Ilya Kulakov
Ilya Kulakov

Written by Ilya Kulakov

Tech Entrepreneur and Quality Freak with passion.

No responses yet

Write a response