The problem

Apple has faced three fundamental problems when building defences around macOS (… I am not writing that these concepts also apply to iOS and other *OSs…):

  1. Code integrity
    • How do I know that the binary I am about to run is exactly the one distributed by the developer?
    • How do I detect further modifications/tampering (typical example: malware that “patches” binaries)?
  2. Identity and trust
    • Who created this binary
    • Can I trust this entity?
    • How do I build a chain of trust?
  3. Sandboxing and capabilities
    • What can be accessed by this binary (e.g.: cam, microphone, keychain, …)
    • How can sandboxing be enforced without encoding the rules in kernel?

Apple solution is a Multi-layered system.

Apple did not “solve the problem” with a digital signature. That would have been too simplistic and inefficient. Technically speaking, Apple has built a SuperBlob containing specialised blobs, each addressing a specific task.

This is totally in line with the separation of concerns principle: each blob responds to a specific problem.

The five fundamental blobs

Blob 1: CodeDirectory (slot 0)

This is the beating heart of the solution - everything else is rooted on it.

The problem

The solution

The CodeDirectory blob contains:

Benefit of this solution

Notes

There is a variant - the CodeDirectory Alternate. The slots dedicated to this structure are addressed from 0x1000 onwards and are used for multiple hashing algorithms (SHA1 legacy and SHA-256)


Blob 2: Entitlements (slot 5) and DER entitlements (slot 7)

The problems

The solution


Blob 3: Requirements (slot 2)

The problems