Detection: MacOS Kextload Usage

Description

Detects execution of the kextload command on macOS systems. The kextload utility is used to manually load kernel extensions (KEXTs) into the macOS kernel, which can introduce privileged code at the kernel level. While legitimate for driver installation and system administration, misuse may indicate attempts to install unauthorized, malicious, or persistence-enabling kernel extensions.

 1
 2| tstats `security_content_summariesonly`
 3  count min(_time) as firstTime
 4        max(_time) as lastTime
 5
 6from datamodel=Endpoint.Processes where
 7
 8Processes.process_name = "kextload"
 9
10AND NOT
11
12Processes.process IN (
13    "*-help*",
14    "* -h *"
15)
16
17by Processes.dest Processes.original_file_name Processes.parent_process_id
18   Processes.process Processes.process_exec Processes.process_guid
19   Processes.process_hash Processes.process_id
20   Processes.process_current_directory Processes.process_name
21   Processes.process_path Processes.user
22   Processes.user_id Processes.vendor_product
23
24
25| `drop_dm_object_name(Processes)`
26
27| `security_content_ctime(firstTime)`
28
29| `security_content_ctime(lastTime)`
30
31| `macos_kextload_usage_filter`

Data Source

Name Platform Sourcetype Source
Osquery Results Other 'osquery:results' 'osquery'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
macos_kextload_usage_filter search *
macos_kextload_usage_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1543 Create or Modify System Process Persistence
Exploitation
Installation
DE.CM
CIS 10

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Notable Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Risk Event True
This configuration file applies to all detections of type TTP. These detections will use Risk Based Alerting and generate Notable Events.

Implementation

This detection uses osquery and endpoint security on MacOS. Follow the link in references, which describes how to setup process auditing in MacOS with endpoint security and osquery. Also the TA-OSquery must be deployed across your indexers and universal forwarders in order to have the osquery data populate the data models.

Known False Positives

Administrators installing new drivers could use this application.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message:

Possible kernel extension loaded on $dest$ by $user$ via $process$

Risk Object Risk Object Type Risk Score Threat Objects
dest system 50 process
user user 50 process

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset osquery osquery:results
Integration ✅ Passing Dataset osquery osquery:results

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 2