Search K
Appearance
Appearance
Other ways to support HackTricks:
Unlike Kernel Extensions, System Extensions run in user space instead of kernel space, reducing the risk of a system crash due to extension malfunction.
There are three types of system extensions: DriverKit Extensions, Network Extensions, and Endpoint Security Extensions.
DriverKit is a replacement for kernel extensions that provide hardware support. It allows device drivers (like USB, Serial, NIC, and HID drivers) to run in user space rather than kernel space. The DriverKit framework includes user space versions of certain I/O Kit classes, and the kernel forwards normal I/O Kit events to user space, offering a safer environment for these drivers to run.
Network Extensions provide the ability to customize network behaviors. There are several types of Network Extensions:
Endpoint Security is a framework provided by Apple in macOS that provides a set of APIs for system security. It's intended for use by security vendors and developers to build products that can monitor and control system activity to identify and protect against malicious activity.
This framework provides a collection of APIs to monitor and control system activity, such as process executions, file system events, network and kernel events.
The core of this framework is implemented in the kernel, as a Kernel Extension (KEXT) located at /System/Library/Extensions/EndpointSecurity.kext
. This KEXT is made up of several key components:
The events that the Endpoint Security framework can monitor are categorized into:
User-space communication with the Endpoint Security framework happens through the IOUserClient class. Two different subclasses are used, depending on the type of caller:
com.apple.private.endpoint-security.manager
entitlement, which is only held by the system process endpointsecurityd
.com.apple.developer.endpoint-security.client
entitlement. This would typically be used by third-party security software that needs to interact with the Endpoint Security framework.The Endpoint Security Extensions:libEndpointSecurity.dylib
is the C library that system extensions use to communicate with the kernel. This library uses the I/O Kit (IOKit
) to communicate with the Endpoint Security KEXT.
endpointsecurityd
is a key system daemon involved in managing and launching endpoint security system extensions, particularly during the early boot process. Only system extensions marked with NSEndpointSecurityEarlyBoot
in their Info.plist
file receive this early boot treatment.
Another system daemon, sysextd
, validates system extensions and moves them into the proper system locations. It then asks the relevant daemon to load the extension. The SystemExtensions.framework
is responsible for activating and deactivating system extensions.
ESF is used by security tools that will try to detect a red teamer, so any information about how this could be avoided sounds interesting.
The thing is that the security application needs to have Full Disk Access permissions. So if an attacker could remove that, he could prevent the software from running:
tccutil reset All
For more information about this bypass and related ones check the talk #OBTS v5.0: "The Achilles Heel of EndpointSecurity" - Fitzl Csaba
At the end this was fixed by giving the new permission kTCCServiceEndpointSecurityClient
to the security app managed by tccd
so tccutil
won't clear its permissions preventing it from running.
Other ways to support HackTricks: