Detection: MacOS Hidden Files and Directories

Description

The following analytic detects suspicious creation of hidden files and directories, which may indicate an attacker's attempt to conceal malicious activities or unauthorized data. Hidden files and directories are often used to evade detection by security tools and administrators, providing a stealthy means for storing malware, logs, or sensitive information. By monitoring for unusual or unauthorized creation of hidden files and directories, this analytic helps identify potential attempts to hide or unauthorized creation of hidden files and directories, and helps identify potential attempts to hide malicious operations, enabling security teams to uncover and address hidden threats effectively.

 1
 2| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where
 3
 4(
 5    Processes.process="*chflags *"
 6    Processes.process="* hidden*"
 7)
 8OR
 9(
10    Processes.process="*xattr *"
11    Processes.process="* -wx *"
12    Processes.process="*com.apple.FinderInfo*"
13)
14
15by Processes.dest Processes.original_file_name Processes.parent_process_id
16   Processes.process Processes.process_exec Processes.process_guid
17   Processes.process_hash Processes.process_id
18   Processes.process_current_directory Processes.process_name
19   Processes.process_path Processes.user
20   Processes.user_id Processes.vendor_product
21
22
23| `drop_dm_object_name(Processes)`
24
25| `security_content_ctime(firstTime)`
26
27| `security_content_ctime(lastTime)`
28
29| `macos_hidden_files_and_directories_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_hidden_files_and_directories_filter search *
macos_hidden_files_and_directories_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
T1564.001 Hidden Files and Directories Defense Evasion
Exploitation
DE.AE
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 Risk Event True
This configuration file applies to all detections of type anomaly. These detections will use Risk Based Alerting.

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

Power users or developers utilizing build tools or CI/CD tools could trigger this activity.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message:

Attempt to hide files on $dest$ by $user$ via $process$

Risk Object Risk Object Type Risk Score Threat Objects
dest system 20 process
user user 20 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