Mach-O
What is Mach-O?
Mach-OMach-O is the native executable, object, and shared library format used by macOS, iOS, watchOS, and tvOS for binaries built with Apple's toolchain.
Mach-O (Mach Object) is the binary format used across Apple operating systems — macOS, iOS, watchOS, and tvOS. Every file opens with a magic number (0xFEEDFACF for 64-bit) and a header, followed by a sequence of load commands that tell the dynamic linker (dyld) how to map the image: LC_SEGMENT_64 describes memory segments such as __TEXT and __DATA, LC_LOAD_DYLIB names required libraries, LC_MAIN sets the entry point, and LC_CODE_SIGNATURE points to the embedded signature blob. Universal ("fat") binaries concatenate per-architecture slices (e.g. x86_64 and arm64) behind a fat header.
Security enforcement is layered on this structure: AMFI and Gatekeeper validate the LC_CODE_SIGNATURE, the hardened runtime constrains injection, and notarization adds an Apple-stapled ticket. Analysts use otool -l, codesign --display --verbose, and nm to spot tampering.
Mach-O was central to the February 2021 Silver Sparrow campaign that Red Canary reported on ~29,139 endpoints across 153 countries; its second variant shipped a universal binary with a native arm64 (Apple Silicon) slice — one of the first malware families to do so — though the Mach-O payloads were inert "bystander binaries" printing only "Hello, World!" and "You did it!". Common abuses include DYLD_INSERT_LIBRARIES dylib injection and swapping segments in unsigned or ad-hoc-signed binaries.
flowchart TD
A[Mach-O file] --> B[Fat header?]
B -->|universal| C[Select arch slice<br/>x86_64 / arm64]
B -->|thin| D[Mach header]
C --> D
D --> E[Load commands]
E --> F[LC_SEGMENT_64<br/>__TEXT / __DATA]
E --> G[LC_LOAD_DYLIB<br/>dynamic libraries]
E --> H[LC_CODE_SIGNATURE]
H --> I{AMFI / Gatekeeper<br/>verify signature}
I -->|valid & notarized| J[Execute]
I -->|invalid / tampered| K[Blocked]● Examples
- 01
Inspecting a malicious .app bundle with otool -l and codesign --display to detect a tampered LC_CODE_SIGNATURE.
- 02
An attacker using DYLD_INSERT_LIBRARIES on an unsigned Mach-O to load a malicious dylib.
● Frequently asked questions
What is Mach-O?
Mach-O is the native executable, object, and shared library format used by macOS, iOS, watchOS, and tvOS for binaries built with Apple's toolchain. It belongs to the Application Security category of cybersecurity.
What does Mach-O mean?
Mach-O is the native executable, object, and shared library format used by macOS, iOS, watchOS, and tvOS for binaries built with Apple's toolchain.
How do you defend against Mach-O?
Defences for Mach-O typically combine technical controls and operational practices, as detailed in the full definition above.
What are other names for Mach-O?
Common alternative names include: Mach Object, Mach-O binary.