Detection: MacOS Keychains Dumped

Description

Detects command-line attempts to access or dump macOS Keychain data using native utilities or direct file access. This includes credential dumping via the security utility (e.g. dump-keychain -d), bulk certificate export using security find-certificate, and direct file copying of Keychain database files using utilities such as cat. Keychain files are located in ~/Library/Keychains/, /Library/Keychains/, and /Network/Library/Keychains/. This technique is commonly associated with post-exploitation credential harvesting, where an attacker with local access seeks to escalate privileges or move laterally by obtaining stored credentials for applications, Wi-Fi networks, system services, and certificates.

 1
 2| tstats `security_content_summariesonly`
 3  count min(_time) as firstTime
 4        max(_time) as lastTime
 5        values(Processes.parent_process) AS parent_process
 6        values(Processes.parent_process_exec) AS parent_process_exec
 7        values(Processes.parent_process_id) AS parent_process_id
 8        values(Processes.parent_process_name) AS parent_process_name
 9        values(Processes.parent_process_path) AS parent_process_path
10
11FROM datamodel=Endpoint.Processes WHERE
12(
13    Processes.process_path="/usr/bin/security"
14    AND
15    (
16        (
17            Processes.process="*dump-keychain*"
18            Processes.process="*-d*"
19        )
20        OR
21        (
22            Processes.process="*find-certificate*"
23            Processes.process="*-p*"
24        )
25    )
26)
27OR
28Processes.process="*keychaindump*"
29OR
30(
31    Processes.process_name IN (
32        "cat",
33        "cp",
34        "dd",
35        "mv"
36    )
37    Processes.process="*Library/Keychains/*"
38    Processes.process="*.keychain*"
39)
40by Processes.action Processes.dest Processes.process Processes.process_hash
41Processes.process_id Processes.process_name Processes.process_path
42Processes.user Processes.vendor_product
43
44
45| `drop_dm_object_name(Processes)`
46
47| `security_content_ctime(firstTime)`
48
49| `security_content_ctime(lastTime)`
50
51| `macos_keychains_dumped_filter`

Data Source

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

Macros Used

Name Value
security_content_summariesonly summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config``
macos_keychains_dumped_filter search *
macos_keychains_dumped_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
T1555.001 Keychain Credential Access
Exploitation
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 Finding (Notable) Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Intermediate Finding (Risk Event) Yes
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

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 accessing keychain files for troubleshooting or endpoint management.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
Keychains dumped on $dest$ by $user$ via $process$ user user 50

Intermediate Findings

Message Entity Field Entity Type Risk Score
Keychains dumped on $dest$ by $user$ via $process$ dest system 50

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: 4