apple-knowledge

repository·main·Indexed 23 days ago

https://github.com/hack-different/apple-knowledge

A collection of reverse engineered Apple formats, protocols, and hardware data for jailbreakers and security researchers. It includes resources on bootloader and kernel protocols (EFI, NVRAM, iBoot, SecureROM), disk formats (APFS, LwVM, dmg), serialization formats (plists, iTunes databases), and code signature formats (Mach-O, img4). The project provides the apple-data package for Node.js, Python, and Ruby to access hardware data files, and documentation on the Apple USB Type-C Port Controller (ACE) and 4CC Master Index.

Tokens
76.7K
Snippets
92
Records
330
Agent score
78%

What's inside apple-knowledge

  1. Overview of Apple Silicon Virtualization.framework

    main
    The Virtualization.framework on Apple Silicon is designed for arm64e architectures only. In this environment, AVPBooter.bin functions as the SecureROM. The framework utilizes a para-virtualization model where iBoot uses "hypercalls" to access synthetic services (SysCfg, NVRAM, and Firmware) that are bound into the device tree via the utils node by AVPBooter and iBoot.
  2. Overview of Apple documentation and data formats

    main
    The Apple Documentation Project provides knowledge and documentation regarding the various formats, protocols, and services used within the Apple ecosystem. This includes file formats (archives, Mach-O binaries, signatures), wireless and wired protocols, data transport mechanisms, debug protocols, and web services. Developers use this project to understand the structures required for binary analysis, protocol fuzzing, and device interaction.
  3. Key features of the APFS filesystem

    main

    APFS (Apple Filesystem) replaced HFS+ and introduced several low-level architectural improvements:

    • Flash/4k Support: Optimized for flash storage and 4k page sizes.
    • Logical Volume Grouping: Replaced the older CoreStorage mechanism.
    • Snapshotting: Uses copy-on-write (CoW) for features like Time Machine; the system volume itself functions as an atomic, signed snapshot.
    • Volume Roles: Defines specific roles for partitions such as System, Data, Preboot, and Update to better support read-only system architectures.
    • Signed System Volumes (SSV): Provides cryptographic verification of the system volume.
  4. Identify the primary researchers for T2 and bridgeOS

    main

    The research into T2 and bridgeOS was conducted by a specific group of researchers, building upon the checkm8 exploit provided by @axi0mX.

    Primary Researchers:

    • @h0m3us3r: Focused on T2 BootROM offsets for checkm8, USB-C debug probe research, and SWD (Serial Wire Debug) via homemade probes.
    • @aunali1: Developed the toolchain/SDK for bridgeOS, SSH from host macOS via NCM interface, and created keylogger/zero-click DFU PoCs.
    • @mcmrarm: Reverse engineered T2 Mac OS drivers, communication protocols, and the T2 boot chain (kernel and user-space) to support Linux and find attack vectors.
    • @su_rickmark: Focused on macOS integrity, EFI, idevicerestore concerns, and the security impact of the T2 chip and USB-C power delivery pins.
  5. Understand the macOS Security Threat Model

    main

    The macOS security model relies on a complex interplay of hardware (SEP), firmware (iBoot, sepOS), and local policies. Key areas of concern for security researchers and developers include:

    • Encryption of Boot Components: Unlike Intel EFI, iBoot and sepOS are encrypted, making independent verification of the early boot process difficult.
    • Local Policy Reductions: The recoveryOS policy is stored on disk and can be subject to lpol reductions to asmb (Apple Secure Multi Boot), potentially targeting undocumented smb5 values.
    • Persistence of Identity Keys: Because the Owner, System, and User Identity Keys are backed by the SEP, a failure to reset boot-policy-digests, xART, and nonce-seeds during an erase can allow older policies to be re-applied.
    • Bootloader Re-entrancy: There is no technical measure preventing fuOS from booting into iBoot or macOS, which could allow for insertion into the boot chain if a proper local policy is present.
    • Rosetta Entitlement Retention: Rosetta can retain entitlements during translation, creating a risk where an attacker could pre-poison the AoT cache with malicious translations for core dylibs.
  6. Understand Apple Mach-O File Types

    main
    Mach-O (Mach Object) is the standard file format used by Apple platforms for executables, object files, and shared libraries. For detailed technical specifications on the Mach-O data structures and formats, refer to the dedicated documentation at formats/mach-o within this repository.
  7. Security Analysis of the M1 Boot Process

    main

    The M1 architecture introduces several security regressions compared to previous generations. A primary concern is the use of an encrypted boot-loader (iBoot), which prevents external security verification and independent auditing. While the applevm2 stack leaves much of the M1 boot process visible, the lack of full source access prevents complete verification of the secure-boot-chain.

    Key identified weaknesses include:

    • Lack of External Measurement: There is no high-assurance path to perform measurements (such as hashing regions or reading APTickets) without performing a full device restore.
    • SecureROM Relocation: SecureROM copies its executable region to mutable SRAM. Because this code exists in DRAM, any coprocessor with a DMA path or incomplete SRAM clearing could potentially compromise SecureROM guarantees.
    • ACE (USB-C) Vulnerability: The ACE (USB-C port controller) can push a device into DFU mode without user interaction, lacking a requirement for a physical key press to prevent misuse.
    • PMP/PMGR Risks: Malicious PMP firmware can prevent the DFU flow because the PMP handles the DFU chord. The author suggests returning to a ROM-based DFU entry method.
  8. Security analysis of M1 iBoot and SecureROM

    main

    The M1 architecture uses an encrypted boot-loader (iBoot), which prevents external security verification and full audit of the boot integrity. Unlike previous EFI-based systems, the lack of transparency makes it impossible to verify security guarantees without Apple's source code or NDAs.

    Key security concerns identified include:

    • Verification Gap: The inability to perform external measurements (like hashing regions or reading APTickets) without a full device restore.
    • SecureROM Relocation: SecureROM copies its executable region to mutable SRAM. This introduces risks where coprocessors with DMA paths or incomplete SRAM clearing could potentially compromise SecureROM guarantees.
    • Dev Build Escapes: The existence of "dev build on production hardware" paths allows for the creation of undetectable "blue pill" operating systems by privileged users.
  9. Understanding DataMigration iOS Security Mitigations

    main

    This document outlines security vulnerabilities and proposed mitigations within the iOS DataMigration.framework and its associated XPC workers. The core issue is that the migration system uses a highly privileged plugin host process that runs various dynamic plugins. Because entitlements are tied to the process rather than the specific plugin, a vulnerability in a single plugin (e.g., a contact migration plugin) can allow an attacker to pivot to unrelated high-privilege systems (e.g., keychain or profiles).

    Key security weaknesses identified include:

    • Over-entitled processes: The plugin host holds a strict superset of all entitlements needed by its plugins.
    • Lack of plugin-specific entitlements: There is no mechanism for a dynamically loaded shared object to declare its own specific entitlements (like com.apple.datamigration.plugin).
    • Atomic dlopen risks: The current dlopen mechanism does not allow for a 'preflight' state where a module is mapped as Read-only (R) and inspected for authenticity (via Trust Cache/CDHash) before being granted Execute (X) permissions.
    • execve descriptor persistence: Entitlements checked for an initial process might persist through an execve call, allowing a new binary to inherit open, entitled connections.
    • MobileDevice Framework downgrades: The ability to modify MobileDevice components on the Data partition of macOS allows for downgrading system frameworks without being an entitled process.
  10. What is the Kernel Debug Kit (KDK)?

    main

    The KDK (Kernel Debug Kit) is a collection of assets installed on macOS under /Library/Developer/KDKs used for debugging the Apple Silicon kernel.

    It includes:

    • DEVELOPMENT and KASAN (kernel address sanitizer) kernel versions.
    • dSYM bundles for symbolicating the kernel and extensions, including lldb python helpers.
    • KernelSupport containing non-open-source XNU content required for the Apple Silicon platform.
  11. Conceptual goals of the QEMU Gadget Device USB Stack

    main

    The QEMU Gadget Device USB Stack aims to solve the limitations of traditional USB virtualization (which focuses on exposing physical/virtual devices to a guest OS) by providing a way to test and connect ARM-style 'gadget mode' devices.

    Key architectural goals include:

    • Low-level control: Unlike USB over TCP/IP, this stack must support device enumeration, protocol errors, and precise control of SETUP packets, endpoints, stalls, and enumeration to enable fuzzing and low-level testing.
    • Decoupled lifetimes: The USB bus lifetime should be independent of both the device and the host. This is achieved by using a separate process (a virtual USB controller or usbd) so that a system restart or device reset doesn't destroy the underlying connection.
    • OS Independence: The protocol must be OS-agnostic to allow communication between different operating systems.
    • Security and Local Connectivity: Local connectivity should avoid TCP by default. It proposes a capability model using separate sockets for the 'gadget' end and the 'host' end to allow for distinct user/group permissions, and the ability to restrict access by USB PID/VID and Classes.
    • Async-first design: Since kernel transports are asynchronous, the stack supports async submission/completion. Synchronous semantics are simulated at the client end using timeouts and mutexes/semaphores.
    • Fuzzing support: The stack allows for the submission of RAW frames in addition to traditional Control/Bulk types to support malformed and non-sensical frames.