Unveiling Mac Security: A Comprehensive Exploration of Sandboxing and AppData TCC
Unknown
Black Hat USA 2024 · Day 1 · Briefing
Overview
This Black Hat USA presentation, delivered by John and a senior security researcher from the don.com security lab, delves into the intricate world of macOS userland security, with a specific focus on sandboxing and Transparency, Consent, and Control (TCC) mechanisms. The talk highlights the persistent challenge of achieving Remote Code Execution (RCE) and Local Privilege Escalation (LPE) on Apple's desktop operating system, even in the face of its robust security architecture. The researchers share their extensive findings, including the discovery of over 40 sandbox escape vulnerabilities since July 2023, underscoring the dynamic and evolving nature of macOS security research.

Key moments
- 0:00 Speaker introduction and motivation for Apple vulnerability research
- 2:10 macOS security: SIP, TCC, and attack objectives
- 3:10 General application sandbox escape approach on macOS
- 4:00 macOS Quarantine attribute and Gatekeeper bypass explanation
- 5:00 Live demo: Escaping Microsoft Word sandbox
- 5:30 Blue team defense strategies and detection methods
- 6:20 Summary of key findings and TCC bypass
Unveiling Mac Security: A Comprehensive Exploration of Sandboxing and AppData TCC
Speakers: John, Bug Hunter; Director and Chief Security Researcher, don.com Security Lab
Conference: Black Hat USA
YouTube: https://www.youtube.com/watch?v=v1wIPaJT7x8
Overview
This Black Hat USA presentation, delivered by John and a senior security researcher from the don.com security lab, delves into the intricate world of macOS userland security, with a specific focus on sandboxing and Transparency, Consent, and Control (TCC) mechanisms. The talk highlights the persistent challenge of achieving Remote Code Execution (RCE) and Local Privilege Escalation (LPE) on Apple's desktop operating system, even in the face of its robust security architecture. The researchers share their extensive findings, including the discovery of over 40 sandbox escape vulnerabilities since July 2023, underscoring the dynamic and evolving nature of macOS security research.
The core objective of the research presented was to systematically analyze and exploit macOS userland vulnerabilities, aiming to bypass critical user space security mechanisms to gain full control over a compromised system. This ambition is rooted in the understanding that while macOS offers advanced protections like System Integrity Protection (SIP) and TCC, userland applications and their interactions can still present avenues for exploitation. The speakers emphasized the value of vulnerabilities that can circumvent these protections, particularly sandbox escapes, which are crucial for turning initial access into broader system compromise.
The article will explore the methodologies employed by the researchers, including a general application sandbox escape approach centered on launching non-standard apps. It will detail the role of macOS quarantine attributes in preventing malicious code execution and how attackers might circumvent these safeguards. Furthermore, the presentation touches upon the critical insight that an arbitrary folder creation vulnerability on macOS can be leveraged to achieve a full sandbox escape, and how vulnerabilities in older versions of third-party applications can be abused for TCC bypasses. Ultimately, this talk offers invaluable insights for both offensive security researchers seeking to understand macOS internals and blue teams aiming to bolster their defenses against sophisticated attacks.
Background
▶ Watch: Speaker introduction and motivation for Apple vulnerability research (0:00)
macOS, like other modern operating systems, incorporates a multi-layered security architecture designed to protect user data and system integrity from malicious actors. Central to this architecture are several key mechanisms that the speakers aimed to dissect and bypass:
- System Integrity Protection (SIP): Introduced in OS X El Capitan, SIP is a fundamental security feature that restricts the root user's ability to perform operations on protected parts of the file system and processes. It prevents modifications to critical system files, directories, and preinstalled applications, even by users with root privileges, and disallows the loading of unsigned kernel extensions. SIP creates a secure operating environment by limiting the actions of all users, including those with administrative access, thereby making it significantly harder for malware to establish persistence or tamper with core system components.
- Transparency, Consent, and Control (TCC): TCC is macOS's privacy framework, akin to Android's permission model. It mandates that applications explicitly request user consent before accessing sensitive resources such as the camera, microphone, location services, contacts, calendars, photos, or even specific user folders like Desktop, Documents, and Downloads. A TCC bypass vulnerability is highly prized in the security community because it allows an attacker to access these sensitive user data types without explicit user permission, circumventing a core privacy safeguard. The researchers noted that such bypasses are significantly more valuable on macOS than on Linux due to the deeper integration and stricter enforcement of TCC.
- Application Sandboxing: macOS applications are typically run within a sandbox, a restrictive environment that limits their access to system resources and user data. The sandbox defines a set of entitlements that dictate what an application can and cannot do, such as accessing specific files, network connections, or hardware components. The primary goal of sandboxing is to contain potential damage from a compromised application, preventing it from interacting with the rest of the system or other applications in unauthorized ways. Escaping this sandbox is often a prerequisite for an attacker to achieve broader system control or access sensitive user data.
The problem that the researchers addressed is the inherent tension between robust security mechanisms and the complex interactions within a userland environment. While SIP, TCC, and sandboxing are designed to create a secure fortress, the sheer complexity of modern applications, third-party libraries, and operating system interfaces inevitably introduces potential vulnerabilities. The speakers' previous work, highlighted by their lab's discovery of over 200 CVEs across major platforms and multiple Pwn2Own awards, underscores a deep expertise in uncovering these subtle flaws. Their shift to Apple security research was motivated by what they perceived as better vulnerability disclosure policies and higher bug bounties, indicating a mature and rewarding ecosystem for security researchers. The ultimate goal remains consistent: to identify and exploit these vulnerabilities to achieve the highest impact, namely RCE and LPE.
Key Findings
▶ Watch: General application sandbox escape approach on macOS (3:10)
The research presented by John and the don.com security lab team yielded several critical findings that shed light on the current state of macOS userland security, particularly concerning sandbox escapes and TCC bypasses. These discoveries highlight both novel attack vectors and enduring challenges for Apple's security model.
Firstly, a standout finding was the revelation that an arbitrary folder creation vulnerability on macOS is functionally equivalent to discovering a sandbox escape vulnerability. This means that if an attacker can trick a sandboxed application into creating a folder at an arbitrary location on the file system, they can leverage this capability to break out of the application's confined environment. This is a powerful primitive, as it can enable the construction of malicious application bundles in strategic locations that might bypass other security checks, ultimately leading to arbitrary code execution outside the sandbox.
Secondly, the researchers conducted a thorough exploration of the macOS quarantine attribute feature. This security mechanism is designed to prevent harmful files from being executed or opened without explicit user consent. The talk detailed its internal workings, including the different parts of the attribute and, crucially, how its implementation can be vulnerable. Understanding how quarantine flags are set and modified (e.g., the 0x40 flag indicating user permission) provided insights into potential bypasses, allowing malicious applications to execute without the typical Gatekeeper warnings.
Thirdly, the presentation revealed that the team had discovered an astonishing number of over 40 sandbox escape vulnerabilities since July 2023 alone. This significant volume of findings indicates a widespread presence of such flaws within macOS, making the operating system more susceptible to attacks than might be commonly perceived. The researchers noted that Apple's capacity to patch these vulnerabilities was overwhelmed, leading them to omit some specific details from the public presentation to prevent immediate widespread exploitation. This underscores the severity and pervasiveness of the issues uncovered.
Finally, a crucial insight into TCC bypasses was presented: the ability to abuse vulnerabilities in old data versions of third-party applications to circumvent TCC protections. While specific technical details on how this was achieved were sparse in the public talk, this finding points to the enduring risk posed by legacy software components or data formats. Attackers can potentially leverage flaws in how older application versions handle data or permissions to gain unauthorized access to sensitive user resources, effectively bypassing the TCC framework. This highlights the importance of keeping all software, including third-party applications, up to date and considering the security implications of older data formats.
These key findings collectively paint a picture of an active and successful research effort that has significantly contributed to the understanding of macOS security weaknesses. They provide actionable intelligence for both offensive and defensive security practitioners, emphasizing the critical importance of secure application development, diligent patching, and comprehensive monitoring.
Technical Deep Dive
▶ Watch: macOS Quarantine attribute and Gatekeeper bypass explanation (4:00)
The technical core of the presentation centered on the methodologies for achieving Remote Code Execution (RCE) and Local Privilege Escalation (LPE) on macOS, with a particular emphasis on breaking out of application sandboxes. The speakers categorized remote attack surfaces into several types, ultimately focusing on document-based attacks, which necessitate a sandbox escape to achieve RCE.
The general approach to escaping an application sandbox on macOS, as detailed by the researchers, involves three potential methods, with the talk concentrating on the third: launching a fully controlled non-standard sandboxed application. This method leverages the ability to craft and execute an application bundle in a way that subverts typical security checks.
The simplest app structure for this purpose involves creating a directory hierarchy like Halog.app/Contents and placing an executable file directly within the Contents folder. This structure, while seemingly innocuous, forms the basis of a macOS application bundle. The executable file's format would depend on the target machine's architecture; the researchers primarily tested their exploits on Intel MacBooks, noting that Apple Silicon (M-series chips) might require minor adjustments. The ability to create such a structure at an arbitrary location, as enabled by an arbitrary folder creation vulnerability, is the critical enabler for this sandbox escape technique.
A significant hurdle for this attack vector is the macOS quarantine attribute. This attribute is automatically assigned to files downloaded from the internet or modified by sandboxed applications, serving as a protective measure against untrusted code. The quarantine attribute is composed of four parts, with the quarantine flags being the most critical for this discussion. When a user downloads a file (e.g., via Safari), it's tagged with this attribute. If the user attempts to launch an application with the quarantine attribute, Gatekeeper, macOS's malware prevention system, will block the launch and prompt the user.
The process for a user to override Gatekeeper is multi-step:
- Gatekeeper blocks the initial launch attempt.
- The user must navigate to System Settings (or Security & Privacy preferences in older macOS versions) to explicitly allow the operation for that specific application.
- Upon clicking "Open" in System Settings, a new dialog box appears, requiring the user to click "Open" once more to confirm their intent.
- Crucially, after this two-step user consent, a system command adds the
0x40flag to the application's quarantine attribute. This flag signifies that the user has explicitly permitted the application to run. - Consequently, the next time the user attempts to launch the same application, Gatekeeper will not block it because the
0x40flag indicates prior approval.
The vulnerability, implicitly, lies in the ability to either:
- Bypass the initial Gatekeeper check entirely by crafting the application bundle in a trusted location or via a trusted process.
- Manipulate the quarantine attribute, specifically setting the
0x40flag without full user interaction, or leveraging the arbitrary folder creation to place the malicious app in a context where quarantine checks are less stringent or entirely absent. The equivalence of arbitrary folder creation to sandbox escape strongly suggests that this primitive allows for the placement of the malicious application bundle in a way that circumvents or manipulates the quarantine mechanism.
The researchers also highlighted that previous exploits often involved the use of sensitive APIs with arguments containing directory traversal sequences (e.g., ../). These sequences are commonly used to navigate outside of an intended directory, and in the context of file or folder creation, could allow an attacker to write files or create directories in arbitrary locations. This, combined with container URLs or security application group identifiers, can provide a powerful means to establish the malicious app structure or manipulate existing application data in a way that leads to a sandbox escape or TCC bypass. For instance, creating a symbolic link (symlink) to a sensitive location within a sandboxed application's container, and then having the application write to that symlink, could lead to a write operation outside the sandbox.
The talk alluded to the exploitation of old data versions of third-party applications for TCC bypasses. While specific examples were withheld, this generally implies vulnerabilities in how these older applications handle file paths, entitlements, or process communication. An attacker might exploit a flaw in an outdated component to trick it into performing an action that a modern, TCC-protected application would not be allowed to do, thereby gaining unauthorized access to sensitive resources. This could involve manipulating configuration files, leveraging insecure IPC (Inter-Process Communication), or exploiting deserialization vulnerabilities.
In summary, the technical deep dive revealed a sophisticated understanding of how macOS security mechanisms can be chained together and subverted. The ability to create arbitrary folders, manipulate application bundles, and understand the intricacies of the quarantine system provides a powerful foundation for achieving sandbox escapes, which are a critical step towards full system compromise.
Demo / Proof of Concept
▶ Watch: Blue team defense strategies and detection methods (5:30)
During the presentation, the speakers provided a clear demonstration of a successful sandbox escape on macOS. While the full intricate steps of the exploit chain were not detailed in the transcript, the outcome was explicitly stated: "Here is a demo. As we can see, I have escaped from the Microsoft Word sandbox."
This brief but impactful statement confirms that the researchers were able to execute code outside the confined environment of a prominent, widely-used application like Microsoft Word. The demonstration served as concrete evidence of the efficacy of their identified vulnerabilities and the methodologies employed. Escaping the sandbox of an application like Microsoft Word is particularly significant because such applications often handle user-generated content, making them a common initial vector for attackers (e.g., via malicious documents).
The demonstration would likely have shown the malicious code, previously confined within Word's sandbox, performing an action that it should not have been able to do, such as writing a file to an arbitrary system location, launching an unauthorized process, or accessing sensitive user data outside its designated container. This visual proof reinforced the claims made about the equivalence of arbitrary folder creation to sandbox escapes and the potential for bypassing macOS's layered defenses. The success of this proof of concept underscores the practical implications of the research for real-world attack scenarios and the importance of addressing these vulnerabilities.
Defensive Implications
▶ Watch: Summary of key findings and TCC bypass (6:20)
The insights gleaned from this research offer critical guidance for security defenders, particularly those responsible for securing macOS environments. The findings highlight specific areas where organizations should focus their efforts to detect and prevent sophisticated attacks leveraging sandbox escapes and TCC bypasses.
Firstly, a primary recommendation for blue teams is to monitor sensitive API usage within their macOS endpoints. The researchers noted that previous exploits often involved arguments containing directory traversal sequences (e.g., ../), container URLs, or security application group identifiers. These are indicators of attempts to manipulate file paths, access restricted application data, or exploit inter-application communication. Endpoint Detection and Response (EDR) solutions and other security tools leveraging the Endpoint Security Framework (ESF) should be configured to log and alert on such suspicious API calls, especially when originating from sandboxed applications or processes that typically shouldn't be engaging in such operations.
However, a significant challenge was acknowledged: due to limitations imposed by Apple's ISP (likely referring to System Integrity Protection or API restrictions), comprehensive detection of these specific API usages directly on employee endpoints might be difficult or impossible for third-party security vendors. This constraint necessitates a shift in defensive strategy for certain types of monitoring.
Given these limitations, the speakers suggested deploying dynamic sandboxes within controlled environments, such as a corporate mail gateway. In this scenario, suspicious email attachments (e.g., malicious documents) could be detonated and analyzed within an isolated, instrumented sandbox. This allows for the dynamic observation of application behavior, including API calls, file system interactions, and process launches, without impacting production endpoints. If a malicious attachment attempts to exploit a sandbox escape or TCC bypass vulnerability, its behavior within the dynamic sandbox can be detected, allowing the organization to block the threat before it reaches an end-user.
Secondly, EDRs and tools built upon the Endpoint Security Framework should specifically monitor symbolic links (symlinks) to sensitive locations. Attackers frequently use symlinks as part of an exploit chain. By creating a symlink from a location they control (e.g., within an application's writable sandbox container) to a sensitive, protected directory, they can trick a legitimate process or even the operating system into performing a write or read operation to the protected location. Monitoring the creation, modification, or access patterns involving symlinks that point to critical system directories, user data folders, or application bundles can be a strong indicator of malicious activity. Abnormal symlink activity, particularly when initiated by applications that do not typically create such links, should trigger immediate alerts for investigation.
Finally, the finding regarding TCC bypasses through vulnerabilities in old data versions of third-party applications underscores the critical importance of a robust patching and software update strategy. Organizations must ensure that all third-party applications are kept up-to-date and that legacy or unsupported software is identified and retired. Furthermore, IT and security teams should regularly audit their application inventory for any components that handle data in ways susceptible to exploitation, especially when dealing with older file formats or deserialization processes. Implementing application whitelisting can also help prevent the execution of unauthorized or vulnerable applications.
In essence, defending against these types of macOS vulnerabilities requires a multi-pronged approach combining endpoint monitoring for specific behaviors, dynamic analysis in controlled environments, and a strong focus on software hygiene and patching.
Key Takeaways
- Arbitrary folder creation on macOS is a critical primitive: The ability to create folders at arbitrary locations is equivalent to a full sandbox escape vulnerability, allowing attackers to construct malicious application bundles outside their confined environment.
- Understand macOS quarantine attributes: The quarantine attribute, particularly the
0x40flag, plays a crucial role in macOS security. Attackers aim to bypass or manipulate this mechanism to achieve unauthorized code execution without user consent. - Third-party application vulnerabilities enable TCC bypasses: Exploiting flaws in "old data versions of third-party applications" can circumvent Transparency, Consent, and Control (TCC), granting unauthorized access to sensitive user data.
- Monitor sensitive API usage and symbolic links: Defenders should implement EDR solutions and Endpoint Security Framework tools to monitor for sensitive API calls involving directory traversal (
../), container URLs, and the creation or manipulation of symbolic links to sensitive locations. - Leverage dynamic sandboxes for detection: Due to limitations in endpoint monitoring, organizations should utilize dynamic sandboxes in environments like mail gateways to detect malicious attachments exploiting these vulnerabilities before they reach endpoints.
- Prioritize software updates and hygiene: Keep all macOS applications, especially third-party software, updated to mitigate risks from vulnerabilities in older versions and data handling mechanisms.
About the Speaker(s)
The presentation was delivered by a team of accomplished security researchers from the don.com security lab.
John, one of the key speakers, is a dedicated bug hunter with a broad focus spanning Android, IoT, and Apple products. His transition from Android to Apple vulnerability research was motivated by what he described as a more favorable vulnerability disclosure policy and higher bug bounties within the Apple ecosystem. John has developed an innovative system utilizing FPGA and Unity to simulate fast Android applications, a methodology he has successfully adapted for macOS and iOS vulnerability analysis. His primary research goals revolve around dissecting macOS userland vulnerabilities, identifying rapid exploitation targets, and ultimately bypassing all user space security mechanisms to gain comprehensive control over compromised systems.
The second speaker, whose name was not explicitly stated in the transcript but is affiliated with the don.com security lab, serves as the Director and Chief Security Researcher of the lab. This individual leads a highly successful team within the information security division of don.com. The lab boasts an impressive track record, having discovered more than 200 CVEs across major technology platforms including Google, Apple, Samsung, and Huawei. Their expertise is further validated by their members being Pwn2Own winners, and the lab itself received a prestigious award in 2022 for the best privilege escalation vulnerability. Their collective focus lies in security architecture and bug hunting across mobile and general security domains, demonstrating a deep and proven capability in uncovering critical software flaws.