<?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>Process-Monitoring — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/process-monitoring/</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/process-monitoring/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>Leveraging Apple's Endpoint Security Framework for Process Monitoring</title><link>https://feed.craftedsignal.io/briefs/2024-01-macos-endpoint-security-framework/</link><pubDate>Tue, 02 Jan 2024 10:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-macos-endpoint-security-framework/</guid><description>This brief discusses the use of Apple's Endpoint Security Framework in macOS 10.15 and later for user-mode process monitoring, offering improved capabilities over the older OpenBSM subsystem.</description><content:encoded><![CDATA[<p>This document explores the use of Apple&rsquo;s Endpoint Security Framework, introduced in macOS 10.15 (Catalina), as a modern alternative to the OpenBSM subsystem for process monitoring. The Endpoint Security Framework provides a user-mode API that offers a simpler interface, comprehensive code-signing information, and proactive event response capabilities. This allows developers to create robust security tools for macOS without relying on kernel-level access, which Apple is actively deprecating. The framework requires the <code>com.apple.developer.endpoint-security.client</code> entitlement and the use of Xcode 11 or later with the macOS 10.15 SDK or newer. This framework enables process monitoring with details such as process ID, path, arguments, and code-signing information, simplifying the development of security tools like Ransomwhere?, TaskExplorer, and BlockBlock.</p>
<h2 id="attack-chain">Attack Chain</h2>
<p>This attack chain represents how a malicious actor can potentially bypass security measures by exploiting the capabilities of process monitoring frameworks:</p>
<ol>
<li><strong>Initial Access:</strong> A malicious program gains initial access to the macOS system through a vulnerability or social engineering.</li>
<li><strong>Privilege Escalation:</strong> The program attempts to escalate privileges to gain broader access to the system.</li>
<li><strong>Process Creation:</strong> The attacker creates a new process (e.g., <code>/tmp/evil.sh</code>) to execute malicious code on the system using <code>es_event_type_notify_exec</code>.</li>
<li><strong>Code Injection:</strong> The malicious process injects code into another running process to hide its activities.</li>
<li><strong>Data Exfiltration:</strong> The injected code collects sensitive data and attempts to exfiltrate it from the system.</li>
<li><strong>Persistence:</strong> The attacker establishes persistence by creating a launch agent or daemon.</li>
<li><strong>Defense Evasion:</strong> The attacker attempts to evade detection by modifying system files or disabling security tools.</li>
<li><strong>Impact:</strong> The attacker achieves their objectives, such as stealing sensitive data, disrupting system operations, or gaining control of the system.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The successful exploitation of process monitoring frameworks and the subsequent bypass of security measures can lead to various detrimental outcomes. This includes unauthorized access to sensitive data, system compromise, and the disruption of critical services. The number of affected systems can range from individual machines to entire networks, depending on the scope of the attack.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Enable Endpoint Security Framework logging to capture process execution events (<code>es_event_type_notify_exec</code>) for enhanced visibility.</li>
<li>Monitor for unexpected or unauthorized process creations, especially in sensitive directories like <code>/tmp</code> or <code>/var/tmp</code>, using a Sigma rule targeting <code>es_event_type_notify_exec</code>.</li>
<li>Implement code-signing verification to ensure that only trusted processes are allowed to execute, leveraging process code signing information.</li>
<li>Develop a detection rule to identify processes lacking proper code signatures or exhibiting suspicious signing characteristics.</li>
<li>Monitor the ES_NEW_CLIENT_RESULT_ERR_NOT_ENTITLED error to detect unauthorized attempts to leverage the Endpoint Security framework.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>macos</category><category>endpoint-security</category><category>process-monitoring</category><category>defense-evasion</category><category>discovery</category></item></channel></rss>