<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>BlockBlock — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/blockblock/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 03 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/blockblock/feed.xml" rel="self" type="application/rss+xml"/><item><title>macOS Kernel-to-Userland Process Creation Notification via undocumented kev_msg_post</title><link>https://feed.craftedsignal.io/briefs/2024-01-kev-msg-post-process-creation/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-kev-msg-post-process-creation/</guid><description>The kev_msg_post function can be abused by malware to broadcast process creation notifications from a kernel extension (kext) to a user-mode application, potentially bypassing security tools that rely on standard APIs and leading to undetected malicious activity.</description><content:encoded><![CDATA[<p>This threat brief describes the abuse of the undocumented <code>kev_msg_post</code> function in macOS to broadcast process creation notifications from a kernel extension (kext) to a user-mode application. This technique, highlighted in Objective-See&rsquo;s research, allows a kext to bypass standard userland APIs for process monitoring. The <code>kev_msg_post</code> function is part of the Kernel Events API. It&rsquo;s designed for kernel-to-userland communication but lacks proper documentation, which makes it difficult to monitor.</p>
<p>The communication involves a kext utilizing <code>kev_msg_post</code> to send data to a user-mode application through a system socket.  Objective-See&rsquo;s BlockBlock tool uses this technique to correlate persistent file I/O events with the responsible process.  Abuse of <code>kev_msg_post</code> can allow malicious kexts to exfiltrate sensitive kernel-level information or trigger actions in user-mode without detection by conventional monitoring tools. This technique is relevant to defenders because it provides a stealthy mechanism for malware to operate within macOS, potentially leading to undetected data theft, privilege escalation, or system compromise.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>A malicious kext is loaded into the macOS kernel, often requiring elevated privileges or exploiting a vulnerability.</li>
<li>The kext uses the <code>kev_vendor_code_find</code> function to obtain a vendor ID associated with the kext (e.g., &ldquo;com.objective-see&rdquo;).</li>
<li>The kext registers for process execution events using kauth or MAC policies.</li>
<li>When a new process is created, the kext&rsquo;s callback function is triggered.</li>
<li>The kext populates a <code>kev_msg</code> structure with process information, including the process ID (PID), user ID (UID), parent process ID (PPID), and path to the executable.</li>
<li>The kext calls the undocumented <code>kev_msg_post</code> function to broadcast the process information to a system socket.</li>
<li>A user-mode application with a socket connected to the same vendor ID receives the broadcasted message, extracting the process information.</li>
<li>The attacker can use the process information for malicious purposes, such as injecting code into the new process, monitoring its activity, or terminating it.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation could allow attackers to monitor and manipulate processes on a compromised macOS system without detection by standard userland monitoring tools.  This could lead to data exfiltration, privilege escalation, or other malicious activities. Due to the nature of the kernel, even a single successful compromise can lead to complete system compromise.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Monitor for the loading of unsigned or untrusted kernel extensions using system integrity monitoring tools that track kext loading events.</li>
<li>Implement detections for user-mode applications creating system sockets with the <code>SYSPROTO_EVENT</code> protocol, as described in the &ldquo;Receiving the Data in User-Mode&rdquo; section. This can be done using an endpoint detection and response (EDR) solution or auditd.</li>
<li>Develop YARA rules to scan kernel memory for the presence of kexts using the undocumented <code>kev_msg_post</code> function to detect malicious kexts attempting to communicate outside kernel space.</li>
<li>Audit the use of <code>ioctl</code> calls with <code>SIOCGKEVVENDOR</code> and <code>SIOCSKEVFILT</code> to detect user-mode applications attempting to filter for specific kernel events, using the code samples from the &ldquo;Receiving the Data in User-Mode&rdquo; section as reference.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>kernel-extension</category><category>kev_msg_post</category><category>macos</category><category>process-monitoring</category></item><item><title>macOS File Monitoring via Endpoint Security Framework</title><link>https://feed.craftedsignal.io/briefs/2024-01-macos-file-monitor/</link><pubDate>Tue, 02 Jan 2024 18:41:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-macos-file-monitor/</guid><description>Objective-See details how to create a file monitor for macOS 10.15 using Apple's Endpoint Security Framework to capture file I/O events and process information.</description><content:encoded><![CDATA[<p>This brief examines the creation of a file monitor on macOS 10.15 (Catalina) using Apple&rsquo;s Endpoint Security Framework, as detailed by Objective-See. This framework offers a user-mode interface to a new Endpoint Security Subsystem, providing a simplified API and comprehensive process information. The file monitor can capture file I/O events, file paths, and process details like process ID, path, and code-signing information. Objective-See highlights the limitations of older file monitoring methods like <code>/dev/fsevents</code> and OpenBSM, which lack detailed process information or face deprecation. This new framework aims to address these limitations, enabling more robust user-mode security tools. Tools like Ransomwhere? and BlockBlock use file monitoring for detecting ransomware and persistence events respectively, demonstrating its importance in macOS security.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker gains initial access to the system (e.g., through exploitation or social engineering).</li>
<li>Attacker executes a malicious binary or script.</li>
<li>The malicious process creates or modifies a file on the system.</li>
<li>The Endpoint Security Framework captures the file I/O event.</li>
<li>The file monitor, leveraging the Endpoint Security Framework, receives a notification about the event.</li>
<li>The file monitor extracts information about the event, including the process ID, path, code-signing information, and the type of file event (e.g., create, write).</li>
<li>Based on the extracted information, the file monitor determines if the event is malicious (e.g., rapid creation of encrypted files, persistence attempt).</li>
<li>The file monitor alerts the user or security system about the malicious activity.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>A successful attack can lead to various detrimental outcomes, including data encryption by ransomware, persistent malware installation, and unauthorized access to sensitive information. File monitors, such as the one described, aim to detect and prevent such attacks. Without proper file monitoring, malicious activities can go unnoticed, leading to significant data loss, system compromise, and financial damage. The Endpoint Security Framework intends to address the limitations of previous monitoring solutions.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Enable Endpoint Security Framework event collection to monitor file creation events using the <code>ES_EVENT_TYPE_NOTIFY_CREATE</code> event type described in the overview.</li>
<li>Deploy the Sigma rule for detecting file creation by unsigned processes to identify potentially malicious activity (see Sigma rule below).</li>
<li>Monitor for processes with missing or invalid code-signing information, as these may be indicators of malicious activity, using the Endpoint Security Framework&rsquo;s process information detailed in the overview.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>file-monitoring</category><category>endpoint-security</category><category>macos</category></item></channel></rss>