MobDojoStart learning free

iOS Internals · Inside iOS · Lesson 1 of 5

How iOS Is Built

Meet the layers inside an iPhone and the chain of trust that starts it up.

12 min60 XPFree lab

A phone in layers

An iPhone looks like one smooth object, but inside it works like a stack of layers. Each layer does one job and relies on the layer below it. Knowing the layers makes the rest of this track much easier to follow.

Here's how that plays out. When a photo app takes a picture, it doesn't talk to the camera hardware itself. It asks a camera framework, and the operating system checks whether that app has permission before anything reaches the camera.

Apple designs its own chips, and it designs them together with the software. That lets it build security features straight into the silicon. The best-known example is the Secure Enclave, a separate, isolated security processor inside the chip of every iPhone since the iPhone 5s. It has its own protected memory and its own startup code. It guards your Face ID or Touch ID data and the keys that encrypt your files, and Apple designed it to keep them safe even if the main kernel were taken over. Course 2 of this track goes deep on it.

A chain of trust at startup

Every layer from the last task trusts the one beneath it. So what makes sure the bottom layer is genuine? The answer is a chain of trust, built fresh every time an iPhone starts up.

It begins with a small piece of code written into the main chip when the chip is made, stored in ROM (read-only memory). This code is the Boot ROM. It can't be changed afterward, not even by Apple. Because it never changes, Apple calls it the hardware root of trust. It holds Apple's public key, a kind of digital stamp checker. It can confirm that something was signed by Apple, but it can't be used to sign anything.

Startup then goes step by step, and each step checks the next one before handing over control:

Think of a relay race where each runner checks the next runner's ID before passing the baton. If any ID is fake, the race stops.

What happens when a check fails? The iPhone refuses to keep starting up. Depending on which stage failed, it goes into Recovery mode or, at the lowest level, DFU mode (Device Firmware Upgrade). Either way it has to be connected to a computer and restored with genuine Apple software. A tampered iPhone doesn't quietly run tampered code. It stops.

The design has one built-in weakness. Since that first stage can never change, a bug in it can never be fixed by a software update. You'll meet a famous example in module 4.

Test yourself

Can you answer these?

  1. An attacker finds a bug that gives them control of the iPhone's main kernel. Which part was designed to keep Face ID data and file encryption keys protected anyway?
  2. What's the name of the unchangeable first stage that holds Apple's public key and starts the chain? (two words)

Answer them in the app to earn 60 XP.

Answer in the app