Mobile Application Penetration Testing
上QQ阅读APP看书,第一时间看更新

iOS architecture

iOS is the operating system that runs on all Apple mobile devices (iPhones, iPads, and iPods), which it shares with the Darwin foundation (https://en.wikipedia.org/wiki/Darwin_(operating_system)).

Unlike other major operating systems, iOS manages the hardware device and provides the technologies required to build the applications on the platform. There are a few default system apps shipped along with the devices, such as Mail, Calendar, Calculator, Phone, Safari, and so on, which are typically used by users.

It is not possible to run iOS and Mac OS X on any other hardware apart from Apple's, and it is restricted to use iOS on any other mobile device apart from Apple's for security and commercial reasons. This has paved the way for jailbreakers to find iOS jailbreak attacks, which we will discuss in the Jailbreaking section. The attack surface for applications has increased significantly, with more than 1 million applications in App Store.

The iOS architecture is layered, and technologies are packaged as frameworks. A framework typically contains all the necessary libraries that are shared dynamically, and it also consists of images and header files. The following image illustrates the layers of the iOS software stack:

It consists of four abstraction layers:

  • Cocoa Touch
  • Media
  • Core Services
  • Core OS

As development begins, a majority of developers utilize higher-level frameworks due to various factors, such as object-oriented abstractions, it being easy to write code with fewer lines, and also encapsulating other features. However, if one utilizes lower-level frameworks, they have to make sure that their higher-level frameworks do not expose them. The main reason for the attack surface on higher-level frameworks being more is due to a vast majority of development activities taking place using those frameworks. Let's now go ahead and explore the different abstraction layers.

Cocoa Touch

The Cocoa Touch layer is bundled with a crucial set of frameworks, written in Objective-C, and developed based on the Mac OS X Cocoa API. The appearance of any app that you see in iOS is developed using the Cocoa Touch framework. Notifications, multi-tasking, touch-specific inputs, all the high-level system services, and other key technologies are supported by this layer and it also provides basic infrastructure support for an app.

The following is the list of important frameworks that are extensively used in this layer:

  • The Address Book UI framework
  • The Event Kit UI framework
  • The Game Kit framework
  • The iAd framework
  • The Map Kit framework
  • The Message UI framework
  • The Twitter framework
  • The UIKit framework

Media

We often comment on multimedia experiences, particularly on sound clarity and video quality. This role is basically played by the media layer in the iOS stack, which provides the iOS with audio, video, graphics, and AirPlay (over-the-air) capabilities.

As with the Cocoa Touch layer, the media layer includes a set of frameworks that can be utilized by developers:

  • The Assets Library framework
  • The AV Foundation framework
  • The Core Audio framework
  • The Core Graphics framework
  • The Core Image framework
  • The Core MIDI framework
  • The Core Text framework
  • The Core Video framework
  • The Image I/O framework
  • The GLKit framework
  • The Media Player framework
  • The OpenAL framework
  • The OpenGL ES framework
  • The Quartz Core framework

Core services

The core services layer provides the fundamental services that all applications can use. Like other layers, the core services layer provides a list of frameworks:

  • The Accounts framework
  • The Address Book framework
  • The Ad Support framework
  • The CFNetwork framework
  • The Core Data framework
  • The Core Foundation framework
  • The Core Location framework
  • The Core Media framework
  • The Core Motion framework
  • The Core Telephony framework
  • The Event Kit framework
  • The Foundation framework
  • The Mobile Core Services framework
  • The Newsstand Kit framework
  • The Pass Kit framework
  • The Quick Look framework
  • The Social framework
  • The Store Kit framework
  • The System Configuration framework

Core OS

Core OS contains low-level fundamental services and technologies for end users. It comprises the OS X kernel. It taps the I/O reads between the CPUs and device. This is the layer that sits on top of the device hardware, which provides low-level networking, access to external accessories, and fundamental system services such as memory management, filesystem, and so on.

Core OS contains the following frameworks:

  • The Accelerate framework
  • The Core Bluetooth framework
  • The External Accessory framework
  • The Generic Security Services framework
  • The Security framework
Note

Missing Application Layer?

We have not included application layer in the architecture diagram since there are confusions about application layer, assuming the application layer can communicate only to cocoa touch. Which is not true. Apps can communicate with any layer of the iOS software stack.