Impostor Syndrome - Hacking Apple MDMs Using Rogue Device Enrolments

Black Hat Asia 2025 · Day 1 · Briefings

Overview

This talk by Marcel, a security researcher at Form3, delves into a critical vulnerability within Apple's Mobile Device Management (MDM) ecosystem, which he dubs "Impostor Syndrome." The core issue revolves around the surprisingly insecure reliance on device serial numbers for MDM enrollment, allowing attackers to enroll rogue devices into corporate MDM systems. Marcel illustrates how this vulnerability can lead to the exfiltration of highly sensitive company data, including Wi-Fi passwords, internal credentials, and even achieve root access across tens of thousands of devices.

Watch on YouTube

Visual summary for Impostor Syndrome - Hacking Apple MDMs Using Rogue Device Enrolments
Visual summary for Impostor Syndrome - Hacking Apple MDMs Using Rogue Device Enrolments

Key moments

  1. 0:00 Introduction: Root access on 45,000 devices
  2. 2:40 Unusual MDM alert: Phantom device in Brazil
  3. 4:00 How Apple MDM enrollment works (the 'black box')
  4. 5:50 Serial number: The key to rogue MDM enrollment
  5. 7:00 Apple device serial numbers are publicly accessible
  6. 7:30 Successful rogue enrollment by spoofing serial number

Impostor Syndrome - Hacking Apple MDMs Using Rogue Device Enrolments

Speakers: Marcel, Security Researcher at Form3

Conference: Black Hat Asia

YouTube: https://www.youtube.com/watch?v=qFxBneMlYZQ

Overview

This talk by Marcel, a security researcher at Form3, delves into a critical vulnerability within Apple's Mobile Device Management (MDM) ecosystem, which he dubs "Impostor Syndrome." The core issue revolves around the surprisingly insecure reliance on device serial numbers for MDM enrollment, allowing attackers to enroll rogue devices into corporate MDM systems. Marcel illustrates how this vulnerability can lead to the exfiltration of highly sensitive company data, including Wi-Fi passwords, internal credentials, and even achieve root access across tens of thousands of devices.

The research originated from an unusual alert within Form3’s Security Operations Center (SOC), where a duplicate, "phantom" device appeared in their MDM, logging in from an unexpected geographical location. This anomaly sparked an investigation into the underlying mechanisms of Apple MDM enrollment, revealing a fundamental flaw in its security assumptions. Marcel's presentation serves as a stark warning to organizations leveraging Apple MDM solutions, highlighting the ease with which attackers can exploit these weaknesses and offering concrete defensive strategies to mitigate the risks.

The talk is particularly significant because it exposes a long-standing vulnerability, with similar concerns reportedly raised to Apple years ago, yet remaining largely unaddressed. Marcel's findings demonstrate that what was once considered a "black box" of secure, automated device provisioning can be systematically reverse-engineered and exploited, turning corporate MDMs into a potential "slot machine" for attackers, with confidential information and privileged access as the ultimate jackpot.

Background

▶ Watch: Introduction: Root access on 45,000 devices (0:00)

The journey into understanding and exploiting Apple MDM vulnerabilities began, as Marcel describes, with an unusual alert from his company's SOC. A device, supposedly located in Germany, suddenly had a duplicate entry in the MDM system, logging in simultaneously from Brazil. This "phantom device" perplexed the security team, as the original device was still online and functioning normally. Crucially, the only common identifier between the legitimate device and its rogue counterpart was the serial number. This observation formed the initial hypothesis: perhaps MDM enrollment relies solely on the serial number.

To understand this, it's essential to grasp how Apple's MDM ecosystem is designed. Unlike traditional MDM setups that might involve manual agent installation or user consent, Apple's approach, particularly for corporate-owned devices, aims for a seamless, "zero-touch" deployment. Companies register with Apple Business Manager (ABM), an asset registry where all Apple devices purchased directly or from authorized resellers are automatically listed. An organization then configures its MDM server (either on-premise or SaaS) within ABM. When a new device is unboxed and powered on for the first time, it "magically" knows it belongs to the company, displaying the corporate logo and automatically enrolling into the designated MDM. This process, while user-friendly, has historically been a significant "black box" in terms of its underlying security mechanisms for many administrators.

Marcel, coming from a Windows background, initially assumed MDM would involve more explicit user or administrative interaction. However, Apple's design prioritizes automation and ease of deployment. The discovery of the phantom device suggested that this automation might be dangerously simplistic, potentially lacking robust authentication beyond a readily available identifier like the serial number. The fact that the phantom device had entirely different hardware and software versions from the original, yet shared the serial number, strongly supported the theory that the serial number alone was the linchpin of the enrollment process. This realization set the stage for Marcel's deep dive into reverse engineering the MDM enrollment flow to confirm and weaponize this potential vulnerability.

Key Findings

▶ Watch: How Apple MDM enrollment works (the 'black box') (4:00)

Marcel's investigation yielded several critical findings that collectively expose a significant weakness in how Apple MDM solutions handle device enrollment:

  1. Serial Number as the Sole Identifier for Enrollment: The most fundamental finding was the confirmation that Apple's MDM enrollment process, at its initial stage, relies almost exclusively on the device's serial number. When a device first connects to Apple Business Manager, it sends a simple JSON payload containing only its serial number. If this serial number is registered to a company in ABM, the device receives the MDM server address and initiates enrollment. This means that possessing a valid serial number is often sufficient to trigger an MDM enrollment, bypassing multi-factor authentication or device-specific cryptographic proofs.
  1. Public Availability and Predictability of Serial Numbers: Marcel highlighted that Apple serial numbers are "super not secret." They are printed on device packaging, appear in purchase manifests, and can be readily found through OS information pages or even publicly accessible GitHub repositories. Furthermore, the older 10-12 character serial number format (pre-2021) is highly predictable. The format encodes manufacturing location, year, week, a sequential unique identifier, and the model number. This structure makes it "very, very easy to generate perfectly valid serial numbers," enabling attackers to craft or brute-force potential targets.
  1. Client-Side Rate Limiting Bypass: During weaponization efforts, Marcel encountered a client-side "rate limit" where his script stopped working after approximately 10 serial numbers. Reverse engineering revealed this was not an Apple API-side rate limit but a simple client-side validation. The profiles command saves the date of the last enrollment attempt in a local file, and if this file accumulates 10 lines, further attempts are blocked. The bypass was as simple as deleting this file or editing it to remove entries, demonstrating a lack of robust server-side protection against enumeration.
  1. SSO Bypass via Legacy Endpoints: While many organizations implement Single Sign-On (SSO) for their MDM enrollment, Marcel discovered a common misconfiguration that allows bypassing it. MDM solutions often support two endpoints: a newer web-based one and an older XML-based one. Companies might migrate to the new endpoint and enable SSO there, but neglect to secure the legacy endpoint. By editing the downloaded enrollment profile and swapping the newer MDM URL for the older, unsecured one (often found in the initial MDM server response), attackers can bypass SSO "about 60% of the time."
  1. Vast Attack Surface and "Jackpot" Potential: Beyond simply enrolling a rogue device, the key finding is the extensive range of sensitive information and control that can be gained. This includes:
  • Tier 1: Basic company information (support contacts, office locations), VPN certificates, network passwords, EDR agent details, licensed software, internal tools, and local administrator passwords (often transferred in clear text via DSCL).
  • Tier 2: Wi-Fi passwords, which are encrypted and signed per device, but can be extracted in clear text by hooking NSDictionary functions during the profile decryption process.
  • The Jackpot: The discovery of MDM administrators embedding highly sensitive credentials (Slack tokens, GitHub credentials, SharePoint API keys, LDAP passwords) or even direct MDM API keys (with "reverse shell" functionality) within shell scripts deployed through the MDM. Recovering these API keys often grants root access to all enrolled devices (Marcel achieved this on 45,000 devices).

These findings collectively paint a picture of an MDM ecosystem where the foundational trust in device identity is weak, and subsequent administrative practices often exacerbate the risk by exposing critical internal assets.

Technical Deep Dive

▶ Watch: Serial number: The key to rogue MDM enrollment (5:50)

The technical underpinnings of this vulnerability lie in the specifics of Apple's MDM enrollment protocol and common administrative oversights. Marcel meticulously reverse-engineered this "black box" process, building upon the foundational knowledge that the serial number was the primary identifier.

Serial Number Format and Generation:

The Apple serial number is a crucial element. For devices manufactured up to 2021, the format is 10-12 alphanumeric characters. Marcel explained its structure:

  • First characters: Manufacturing location (Marcel only observed two variants, making this nearly static).
  • Next characters: Year of manufacture.
  • Followed by: Week of manufacture.
  • Unique Identifier: A sequential number, likely the literal serial number.
  • Last four characters: Model number (e.g., for a 2019 MacBook Pro).

This fixed, predictable format allows attackers to easily generate "perfectly valid serial numbers" for enumeration or brute-forcing. Alternatively, serial numbers can be harvested from public sources like GitHub or physical device packaging.

The MDM Enrollment Flow:

Marcel detailed the three key players and their interactions during enrollment:

  1. Apple Device: The user's new MacBook, powered on for the first time.
  2. iprofiles.apple.com: Apple's API endpoint for Apple Business Manager.
  3. Company's MDM Server: The server configured by the organization (on-prem or cloud-based).

The process unfolds as follows:

  • Initial Query (Device to ABM): When the device boots, it sends a small JSON message to iprofiles.apple.com. Crucially, this message contains only the device's serial number.
  • ABM Response:
  • If the serial number is not enrolled in any company's MDM, an empty response is returned.
  • If the serial number is enrolled, ABM returns a "massive dictionary" of information. This includes company details like internal support phone numbers, email addresses, MDM contact persons, office locations, and most importantly, the address of the company's MDM server. This information, while not always "super secret," is internal and valuable to an attacker.
  • MDM Server Communication (Device to MDM Server): The device then contacts the MDM server directly. Marcel noted two primary endpoints:
  • Newer, web-based endpoint: Takes a large Base64-encoded payload.
  • Older endpoint: Takes the exact same payload but in XML format.

The payload sent to the MDM server contains basic hardware information, the device's serial number, and a Unique ID (UID). Again, the serial number is the primary identifier used for enrollment.

  • MDM Server Reply: The MDM server replies, and this is where the path diverges:
  • SSO-protected: If the company has configured SSO, the enrollment process will require authentication.
  • No SSO: In "about 60% of the time," Marcel found no SSO, and the enrollment proceeds automatically.

Weaponization and Bypasses:

Marcel's weaponization strategy involved generating or scavenging serial numbers and then using a modified profiles command. He instrumented the profiles command with LLDB to swap serial numbers in memory and capture the MDM server addresses returned by Apple's API. He acknowledged that Duo Security's "MDM, E-Maybe" article (from eight years prior) provided valuable insights into instrumenting this process, highlighting the long-standing nature of these issues.

Two key bypasses were instrumental:

  1. Client-Side Rate Limit: The profiles command locally stores the date of the last 10 enrollment attempts. If this count is reached, further attempts are blocked. Marcel's "epic bypass" was simply to delete or edit this local file, effectively resetting the client-side counter and allowing unlimited enrollment attempts. This is a classic example of security by obscurity or client-side trust.
  2. SSO Bypass via Legacy Endpoints: When an MDM server returns two URLs (one for the new, SSO-protected endpoint and one for the old, often unsecured XML endpoint), an attacker can intercept the downloaded enrollment profile. By editing this profile on disk and replacing the new URL with the old one, enrollment can proceed without SSO. This simple misconfiguration bypass works in approximately 60% of observed cases.

Extracting Wi-Fi Passwords:

Obtaining Wi-Fi passwords proved more challenging due to Apple's design choices. Virtual machines often lack dedicated wireless cards, and Apple's system prevents the installation of wireless profiles on devices without one. Furthermore, network profiles are encrypted and signed with a per-device certificate established during enrollment, making direct decryption difficult. Marcel's solution involved a deep dive into the profile installation process. He found that for the system to reject a Wi-Fi profile, it first had to decrypt it. By hooking the relevant NSDictionary function with LLDB during this decryption phase, he could dump the entire profile, including the Wi-Fi password, in cleartext from memory.

Demo / Proof of Concept

▶ Watch: Apple device serial numbers are publicly accessible (7:00)

Marcel's initial proof of concept was driven by the unexpected SOC alert. To replicate the "phantom device" phenomenon, he leveraged a Hackintosh virtual machine. Specifically, he used the OSX KVM project by Kolia on GitHub, which facilitates creating macOS VMs on Ubuntu.

The core of the demonstration involved:

  1. VM Setup: Creating a macOS virtual machine.
  2. Serial Number Injection: Taking the serial number of the compromised device (or a known corporate device) and injecting it into the VM's configuration. This was achieved by recompiling OpenCore, a bootloader used in Hackintosh setups, with the desired serial number.
  3. Rogue Enrollment: Upon firing up the modified VM, it automatically enrolled into Form3's corporate MDM. This immediately validated the hypothesis that the serial number alone was sufficient for enrollment, creating a second "phantom machine" in their MDM.

While his company's MDM only distributed a free version of Adobe Acrobat and a self-service application, the successful rogue enrollment confirmed the underlying vulnerability. This led Marcel to investigate what other companies might be deploying through their MDMs, effectively expanding his PoC to discover the "prizes" available through such an attack.

The "prizes" described in the talk serve as a detailed extension of the proof-of-concept, illustrating the tangible impact of a successful rogue enrollment:

  • Tier 1 Prizes (Basic Information & Profiles):
  • Company Information: Directly from the ABM response, including support contacts, email, and office locations.
  • Configuration Profiles: These are automatically installed on the rogue device. While some contain benign password policies or EDR agents, others reveal sensitive data like VPN certificates or network passwords.
  • Self-Service Applications: Access to internal tools, custom-developed software, or licensed applications (e.g., Microsoft Office), which can create new attack surfaces.
  • Local Administrator Passwords: MDM agents often create local admin accounts. Marcel found that if admins are "sloppy," they might set the same password across all devices. Because the MDM agent uses DSCL (Directory Service Command Line), these passwords are often transferred in clear text and can be recovered from BPLIST files on the rogue machine.
  • Tier 2 Prizes (Wi-Fi Passwords):
  • This required a more advanced PoC. Since virtual machines typically lack wireless cards, preventing direct profile installation, Marcel had to reverse engineer the profile installation mechanism. By hooking the NSDictionary function with LLDB during the decryption of network profiles (which happens even if the profile can't be installed), he could dump cleartext Wi-Fi passwords from memory. This demonstrated that even encrypted data in transit could be exposed on a compromised endpoint.
  • The Jackpot (Root Access via MDM API Keys):
  • The ultimate PoC involved discovering shell scripts deployed by MDMs. Administrators, facing problems unresolvable by MDM's native features, often embed custom scripts. Marcel found these scripts frequently contained Slack tokens, GitHub credentials, SharePoint API keys, LDAP passwords, and critically, MDM's own API keys.
  • His co-author, Magdalina, identified hidden "reverse shell" functions within MDM APIs. By recovering an MDM API key from a shell script, Marcel could leverage these functions to push arbitrary one-liner shell scripts to any device enrolled in that MDM. This ability effectively granted root access to 45,000 devices simultaneously, demonstrating the catastrophic potential of this vulnerability.

These multi-tiered demonstrations illustrate not only the ease of initial compromise but also the profound depth of access and information exfiltration possible once a rogue device is enrolled.

Defensive Implications

▶ Watch: Successful rogue enrollment by spoofing serial number (7:30)

Marcel provided a comprehensive set of defensive strategies for MDM administrators to mitigate the risks posed by rogue device enrollments and the subsequent exploitation of sensitive data. These recommendations aim to address the vulnerabilities at various layers:

  1. Mandatory SSO for MDM Enrollment:
  • Always enable SSO on your MDM solution. This is presented as "advice zero" – a fundamental security control.
  • Extend SSO to All Endpoints: Critically, administrators must review their MDM documentation (e.g., Postman collections) and ensure that SSO protection applies to all MDM enrollment endpoints, including "legacy" or "legacy device" specific URLs. Marcel noted that older endpoints might default to less secure LDAP-based SSO or have no SSO at all, creating a bypass vector.
  1. Prudent Handling of Credentials in Shell Scripts:
  • Assume Compromise: Administrators must operate under the assumption that any credentials pushed via MDM shell scripts will eventually end up in the hands of users or attackers.
  • Reduce Scope (Least Privilege): If credentials must be included, their scope should be severely restricted. Implement the principle of least privilege, ensuring tokens or API keys can only perform the absolute minimum necessary actions.
  • Avoid MDM API Keys in Scripts: The most critical advice is to never embed the MDM's own API keys into shell scripts. These keys often grant extensive control, including the ability to push reverse shells and gain root access. If absolutely unavoidable, administrators must thoroughly check the key's scope, ideally using the vendor's Postman collection, to ensure no sensitive functions are accessible. Even read access can leak PII.
  1. Secure Local Administrator Passwords:
  • Per-Machine Passwords: Utilize MDM features that allow generating unique, per-machine local administrator passwords instead of pushing a single, static password across all devices. This prevents lateral movement across the fleet if one password is compromised.
  • Avoid Cleartext Transfer: Be aware that tools like DSCL can transfer passwords in cleartext. Review how your MDM handles local account provisioning.
  1. SSO for Self-Service Applications:
  • Enable SSO for Self-Service: If available, enable SSO specifically for the self-service application portal. This acts as a crucial "last line of defense" if other enrollment protections fail, preventing unauthorized access to internal tools and licensed software.
  1. Security Review of MDM Scripts:
  • In-House Security Review: Implement a process for your in-house security team (or a third-party expert) to conduct security reviews of all shell scripts deployed through the MDM. This helps identify embedded credentials, risky operations, and potential privilege escalation vulnerabilities.
  1. Prevent Local Privilege Escalation (LPE) in Scripts:
  • Careful Scripting: MDM agents often run as root. Even small mistakes in shell scripts, such as downloading files to world-writable directories like /tmp or performing risky copy operations, can create race conditions. These can be exploited by local users to achieve root privileges, especially since users can often trigger script executions from self-service. Red teams frequently target these kinds of vulnerabilities.

In summary, defenders need to move beyond assuming Apple's ecosystem is inherently secure and instead adopt a proactive, "assume breach" mindset for MDM deployments. Robust authentication (SSO), strict privilege management, careful credential handling, and thorough security reviews of all custom scripts are paramount to preventing these types of sophisticated attacks.

Key Takeaways

  • Serial Numbers are Insufficient for MDM Trust: Apple's MDM enrollment process critically over-relies on device serial numbers, which are easily discoverable or guessable, allowing rogue devices to enroll into corporate MDM systems.
  • SSO is Imperative (and Must Be Comprehensive): Always enable Single Sign-On (SSO) for MDM enrollment, and critically, ensure it extends to all endpoints, including older or legacy interfaces, to prevent bypasses.
  • Never Embed Sensitive Credentials in MDM Scripts: Avoid placing API keys, passwords, or other secrets directly into shell scripts deployed via MDM. If absolutely necessary, ensure tokens have the narrowest possible scope and verify their permissions thoroughly using vendor documentation.
  • Secure Local Admin Passwords: Implement per-machine unique administrator passwords via your MDM solution to prevent lateral movement across your device fleet if a single password is compromised.
  • Scrutinize MDM Configurations and Scripts: Regularly audit your MDM settings and custom shell scripts for misconfigurations, client-side vulnerabilities (like rate limit bypasses), and potential privilege escalation paths. Assume MDM agents running as root create high-risk scenarios.
  • The "Jackpot" is Real: Successful rogue enrollment can lead to exfiltration of Wi-Fi passwords, internal tools, and, most critically, MDM API keys capable of granting root access to an entire fleet of corporate devices.

About the Speaker(s)

The primary speaker for this talk is Marcel, a security researcher hailing from Hungary. He humorously introduced his home country by mentioning its contributions to the world: the Rubik's Cube and "Hide the Pain Harold." Marcel works for Form3, a remote-first fintech company based in the UK, where his research into macOS security began. His work at Form3 provided the initial impetus for this research after an unusual alert from their Security Operations Center.

Marcel also gave a "huge shout out" to his co-author, Magdalina, for her contributions, particularly in identifying critical functions within MDM APIs during the "jackpot" phase of the research.

Reviews

Dr. Zero (Offensive Security Researcher) — STRONG ACCEPT

This talk presents a deeply researched, highly impactful vulnerability chain within Apple's MDM ecosystem, leveraging the insecure reliance on device serial numbers for initial enrollment. Marcel's work goes beyond theoretical concerns, detailing practical bypasses for client-side rate limiting and SSO, culminating in the exfiltration of sensitive corporate data, including Wi-Fi passwords and MDM API keys that grant root access to tens of thousands of devices. The research is technically sound, offers concrete defensive strategies, and serves as a stark warning to any organization utilizing Apple MDM.

Heather Calloway (CISO) — STRONG ACCEPT

This research uncovers a critical and long-standing vulnerability in Apple's MDM enrollment process, stemming from an over-reliance on easily discoverable serial numbers. Marcel effectively demonstrates how this can lead to rogue device enrollment, bypassing SSO, and ultimately enabling the exfiltration of sensitive corporate data, including MDM API keys capable of granting root access to an entire fleet of devices. The talk provides actionable, practical defensive strategies, making it essential for security leaders to re-evaluate their MDM configurations and script hygiene.

→ Top-rated talks at Black Hat Asia 2025

All talks from Black Hat Asia 2025