<?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>Kev_msg_post — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/kev_msg_post/</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/tags/kev_msg_post/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></channel></rss>