text stringlengths 0 1.99k |
|---|
efforts to harden the platform, IOKit continues to be a frequent source of |
vulnerabilities. Identifying which methods are accessible from user space |
is a first step for vulnerability research in this area. It enables the |
accurate enumeration of all available endpoints, ensuring complete coverage |
during fuzz testing. |
This article outlines a structured methodology for mapping the IOKit |
external methods exposed to user space. By employing a combination of |
static analysis and runtime enumeration, we can identify accessible |
interfaces, pinpoint potential attack vectors, and establish a solid |
foundation for effective fuzzing. Our goal is to enhance the precision and |
effectiveness of IOKit vulnerability research. |
This guide focuses solely on "external methods," but it is important to |
note that IOKit drivers also provide other communication channels, such as: |
- Properties: For reading and writing driver configuration values |
- Notifications: For receiving asynchronous events from the driver |
- Shared memory: For efficient large data transfers |
- External traps: A legacy method (use external methods instead) |
- Shared Data Queue: For bidirectional queued data transfer |
- IOStream: For continuous data streaming |
While this guide does not cover these additional channels, familiarizing |
yourself with the material presented here will help improve your |
understanding of them. |
============================ |
--[ 1 - IOKit Interface Fundamentals |
============================================================================ |
The first part of the guide teaches about the main components of the |
IOKit. It introduces IOKit kernel space components and how to interact with |
them from User Space. |
===================== |
--[ 1.0 - Introduction to IOKit |
============================================================================ |
IOKit is a framework in macOS that allows user-space applications to |
interact with hardware devices, forming part of the XNU kernel. It provides |
C++ classes and APIs for device drivers, abstracting hardware for easier |
management. The framework is documented extensively in Apple's IOKit |
Fundamentals[0]. |
======== |
--[ 1.1 - Registry |
============================================================================ |
Apple's IOKit maintains an IORegistry[1] of all devices in the system, |
organized as a tree structure. Each node (I/O Service instance) in this |
tree represents a device, driver, or attachment point, and the |
relationships between nodes reflect how devices are physically or logically |
connected. Here is an example of device family tree where a Mac machine has |
a USB port, a USB hub is connected to that port, and both a keyboard and |
mouse are plugged into the hub: |
```````````````````````````````````````````````````````````````````````````` |
[Mac] |
| |
+-- [USB Port] |
| |
+-- [USB Hub] |
| |
+-- Keyboard |
+-- Mouse |
```````````````````````````````````````````````````````````````````````````` |
Each item ("Mac", "USB Port", etc.) is an IORegistryEntry[2] object (or an |
object derived from IORegistryEntry), forming the hierarchical structure of |
the IORegistry. |
====== |
--[ 1.1.1 - Planes |
============================================================================ |
IOKit's IORegistry organizes all services in a tree structure that can |
be viewed through different "planes". Each plane[3] represents a distinct |
type of relationship or hierarchy among the same set of objects. The |
previous example of the USB family tree illustrates the Service plane. It |
should be the primary plane for mapping the attack surface in IOKit during |
vulnerability research, as it serves as the root plane. Focusing on other |
planes may result in missing services. |
======== |
--[ 1.1.2 - Services |
============================================================================ |
The IOService[4] is the base class for all drivers in IOKit, |
representing |
hardware devices, virtual devices, or kernel-only system services. These |
services operate with full kernel privileges and direct hardware access. |
User space applications cannot directly instantiate, access, or call |
methods on I/O service objects. |
====== |
--[ 1.1.3 - Driver |
============================================================================ |
Drivers are classes that inherit from superclasses, all ultimately |
deriving from the IOService class. For example, MyUSBDriver inherits from |
IOService, allowing dynamic interaction with it as an IOService object: |
```````````````````````````````````````````````````````````````````````````` |
class MyUSBDriver : public IOService { |
public: |
virtual bool init(OSDictionary *dictionary = NULL) override; |
virtual bool start(IOService *provider) override; |
virtual void stop(IOService *provider) override; |
IOReturn sendCommand(uint8_t cmd, uint32_t value); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.