Dive into Apple UserFS
This talk provides a deep dive into the architecture and security implementation of Apple's UserFS (Userspace Filesystem) on iOS and macOS. The speaker demonstrates how UserFS handles external storage devices and identifies critical vulnerabilities, including out-of-bounds write issues in the kernel-space handling of extended attributes. The research highlights how UserFS, while intended as a security mitigation, introduces new attack surfaces and potential paths for privilege escalation. The presentation includes detailed analysis of the communication flow between userspace daemons and the kernel, as well as the exploitation of specific kernel-space bugs.
How Apple’s UserFS Architecture Creates New Kernel Attack Surfaces
TLDR: Apple’s UserFS was designed to move filesystem logic into userspace to mitigate kernel-level risks, but this research reveals it actually introduces new, exploitable attack surfaces. By analyzing the communication flow between userspace daemons and the kernel, researchers identified critical out-of-bounds write and use-after-free vulnerabilities. Pentesters should focus on the XPC interfaces and the complex state synchronization between UserFS and the kernel to find similar privilege escalation paths.
Security researchers often view moving code from kernel space to userspace as a win for stability and security. The logic is simple: if a parser or driver crashes in userspace, the system stays up, and the blast radius is contained by the sandbox. Apple implemented UserFS on iOS and macOS to handle external storage, hoping to isolate the messy, error-prone code required to support various filesystem formats. However, this research proves that shifting the boundary doesn't eliminate the risk; it just changes the shape of the target.
The Illusion of Isolation
UserFS operates by offloading filesystem operations to a userspace daemon, userfsd. When you plug in an external drive, the kernel detects the device and triggers a launch event. This initiates a communication chain involving livefileproviderd, the UVFSService XPC service, and finally, the specific filesystem plugin (like exfat.dylib).
The core issue is that the kernel still needs to maintain a bridge to this userspace logic. This bridge is implemented via the lfs.kext kernel extension. By analyzing the communication flow, it becomes clear that the kernel is still performing complex operations on data provided by the userspace daemon. If the daemon is compromised or if the communication protocol is flawed, the kernel is essentially trusting input from a process that is now a primary target for exploitation.
Exploiting the Extended Attribute Parser
One of the most significant findings involves the handling of extended attributes (xattrs) in the kernel-space component of UserFS. The research highlights a vulnerability, CVE-2022-42861, where a lack of proper bounds checking during the parsing of these attributes allows an attacker to trigger an out-of-bounds write.
When the kernel processes an xattr, it expects the data to fit within a specific structure. By crafting a malicious filesystem image, an attacker can provide an attribute entry that claims to be larger than the available buffer. Because the validation logic is insufficient, the kernel proceeds to write data into memory regions it shouldn't touch.
// Simplified representation of the vulnerable logic
if (attr_entry_offset + attr_total_size > buffer_size) {
// The check is insufficient or bypassed
// Proceeding to write leads to OOB
}
This is a classic OWASP Memory Corruption scenario. In a real-world engagement, a researcher would use lldb to trace the get_xattr calls and observe how the kernel handles these malformed structures. If you are testing an iOS or macOS device, focus your efforts on the lfs.kext interface. Any input that crosses the boundary from userfsd to the kernel is a potential vector for privilege escalation.
Chaining Primitives for Root
The research also touches on CVE-2022-30937, a vulnerability that demonstrates how a seemingly minor bug can be chained to achieve full system compromise. By leveraging a "message type confusion" in the kernel, an attacker can turn a non-complex message into a complex one. This allows for the manipulation of kernel objects, which can then be used to exploit the xattr bug mentioned earlier.
The impact is severe. By successfully exploiting these flaws, an attacker can move from a sandboxed userspace process to executing code with kernel privileges. This bypasses the very security boundaries that UserFS was intended to reinforce. For those performing red team assessments, the takeaway is that the "mitigation" itself is often the most interesting part of the attack surface.
Defensive Realities
Defending against these types of vulnerabilities is notoriously difficult because they exist in the complex interaction between two privilege domains. For blue teams, the best approach is to monitor for anomalous XPC traffic and unexpected process behavior involving userfsd. Restricting the ability to mount arbitrary external storage via MDM profiles remains the most effective way to eliminate this entire class of risk. If you cannot disable external storage, ensure that your kernel patch levels are current, as Apple has been actively hardening the lfs.kext code in recent releases.
What to Investigate Next
The transition to userspace filesystems is a trend that will likely continue as vendors look for ways to reduce the kernel's footprint. However, as this research shows, the complexity of the interface between userspace and kernel space is where the bugs hide. Don't assume that moving code out of the kernel makes it safe. Instead, look at how the kernel validates the data it receives back from those new, "safe" userspace processes. The next big exploit is likely waiting in the code that handles the return trip.
Vulnerability Classes
Tools Used
Target Technologies
Attack Techniques
Up Next From This Conference

Chained to Hit: Discovering New Vectors to Gain Remote and Root Access in SAP Enterprise Software

Zero-Touch-Pwn: Abusing Zoom's Zero Touch Provisioning for Remote Attacks on Desk Phones

ODDFuzz: Hunting Java Deserialization Gadget Chains via Structure-Aware Directed Greybox Fuzzing
Similar Talks

Hacking Apple's USB-C Port Controller

Unmasking the Snitch Puck: The Creepy IoT Surveillance Tech in the School Bathroom

