Threat Intel Hash Indicator Match

This rule is triggered when a hash indicator from the Threat Intel Filebeat module or integrations has a match against an event that contains file hashes, such as antivirus alerts, process creation, library load, and file operation events.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/05/22"
  3maturity = "production"
  4updated_date = "2024/06/10"
  5
  6[transform]
  7[[transform.osquery]]
  8label = "Osquery - Retrieve DNS Cache"
  9query = "SELECT * FROM dns_cache"
 10
 11[[transform.osquery]]
 12label = "Osquery - Retrieve All Services"
 13query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
 14
 15[[transform.osquery]]
 16label = "Osquery - Retrieve Services Running on User Accounts"
 17query = """
 18SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
 19NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
 20user_account == null)
 21"""
 22
 23[[transform.osquery]]
 24label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
 25query = """
 26SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
 27services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
 28authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
 29"""
 30
 31
 32[rule]
 33author = ["Elastic"]
 34description = """
 35This rule is triggered when a hash indicator from the Threat Intel Filebeat module or integrations has a match against
 36an event that contains file hashes, such as antivirus alerts, process creation, library load, and file operation events.
 37"""
 38from = "now-65m"
 39index = ["auditbeat-*", "endgame-*", "filebeat-*", "logs-*", "winlogbeat-*"]
 40interval = "1h"
 41language = "kuery"
 42license = "Elastic License v2"
 43name = "Threat Intel Hash Indicator Match"
 44note = """## Triage and Analysis
 45
 46### Investigating Threat Intel Hash Indicator Match
 47
 48Threat Intel indicator match rules allow matching from a local observation, such as an endpoint event that records a file hash with an entry of a file hash stored within the Threat Intel integrations index.
 49
 50Matches are based on threat intelligence data that's been ingested during the last 30 days. Some integrations don't place expiration dates on their threat indicators, so we strongly recommend validating ingested threat indicators and reviewing match results. When reviewing match results, check associated activity to determine whether the event requires additional investigation.
 51
 52This rule is triggered when a hash indicator from the Threat Intel Filebeat module or an indicator ingested from a threat intelligence integration matches against an event that contains file hashes, such as antivirus alerts, file operation events, etc.
 53
 54> **Note**:
 55> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 56
 57#### Possible investigation steps
 58
 59- Gain context about the field that matched the local observation. This information can be found in the `threat.indicator.matched.field` field.
 60- Investigate the hash , which can be found in the `threat.indicator.matched.atomic` field:
 61  - Search for the existence and reputation of the hash in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 62  - Scope other potentially compromised hosts in your environment by mapping hosts with file operations involving the same hash.
 63- Identify the process that created the file.
 64  - Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 65  - Enrich the information that you have right now by determining how the file was dropped, where it was downloaded from, etc. This can help you determine if the event is part of an ongoing campaign against the organization.
 66- Retrieve the involved file and examine the host for derived artifacts that indicate suspicious activities:
 67  - Analyze the process executable using a private sandboxed analysis system.
 68  - Observe and collect information about the following activities in both the sandbox and the alert subject host:
 69    - Attempts to contact external domains and addresses.
 70      - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
 71      - Examine the DNS cache for suspicious or anomalous entries.
 72        - $osquery_0
 73    - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
 74    - Examine the host services for suspicious or anomalous entries.
 75      - $osquery_1
 76      - $osquery_2
 77      - $osquery_3
 78- Using the data collected through the analysis, scope users targeted and other machines infected in the environment.
 79
 80### False Positive Analysis
 81
 82- Adversaries often use legitimate tools as network administrators, such as `PsExec` or `AdFind`. These tools are often included in indicator lists, which creates the potential for false positives.
 83
 84### Response and Remediation
 85
 86- Initiate the incident response process based on the outcome of the triage.
 87- Isolate the involved host to prevent further post-compromise behavior.
 88- If the triage identified malware, search the environment for additional compromised hosts.
 89  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 90  - Stop suspicious processes.
 91  - Immediately block the identified indicators of compromise (IoCs).
 92  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 93- Remove and block malicious artifacts identified during triage.
 94- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 95- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 96- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 97"""
 98references = [
 99    "https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-threatintel.html",
100    "https://www.elastic.co/guide/en/security/master/es-threat-intel-integrations.html",
101    "https://www.elastic.co/security/tip",
102]
103risk_score = 99
104rule_id = "aab184d3-72b3-4639-b242-6597c99d8bca"
105setup = """## Setup
106
107This rule needs threat intelligence indicators to work.
108Threat intelligence indicators can be collected using an [Elastic Agent integration](https://www.elastic.co/guide/en/security/current/es-threat-intel-integrations.html#agent-ti-integration),
109the [Threat Intel module](https://www.elastic.co/guide/en/security/current/es-threat-intel-integrations.html#ti-mod-integration),
110or a [custom integration](https://www.elastic.co/guide/en/security/current/es-threat-intel-integrations.html#custom-ti-integration).
111
112More information can be found [here](https://www.elastic.co/guide/en/security/current/es-threat-intel-integrations.html).
113"""
114severity = "critical"
115tags = ["OS: Windows", "Data Source: Elastic Endgame", "Rule Type: Threat Match"]
116threat_index = ["filebeat-*", "logs-ti_*"]
117threat_indicator_path = "threat.indicator"
118threat_language = "kuery"
119threat_query = """
120@timestamp >= "now-30d/d" and event.module:(threatintel or ti_*) and (threat.indicator.file.hash.*:* or
121threat.indicator.file.pe.imphash:*) and not labels.is_ioc_transform_source:"true"
122"""
123timeline_id = "495ad7a7-316e-4544-8a0f-9c098daee76e"
124timeline_title = "Generic Threat Match Timeline"
125timestamp_override = "event.ingested"
126type = "threat_match"
127
128query = '''
129file.hash.*:* or process.hash.*:* or dll.hash.*:*
130'''
131
132
133[[rule.threat_filters]]
134
135[rule.threat_filters."$state"]
136store = "appState"
137[rule.threat_filters.meta]
138disabled = false
139key = "event.category"
140negate = false
141type = "phrase"
142[rule.threat_filters.meta.params]
143query = "threat"
144[rule.threat_filters.query.match_phrase]
145"event.category" = "threat"
146[[rule.threat_filters]]
147
148[rule.threat_filters."$state"]
149store = "appState"
150[rule.threat_filters.meta]
151disabled = false
152key = "event.kind"
153negate = false
154type = "phrase"
155[rule.threat_filters.meta.params]
156query = "enrichment"
157[rule.threat_filters.query.match_phrase]
158"event.kind" = "enrichment"
159[[rule.threat_filters]]
160
161[rule.threat_filters."$state"]
162store = "appState"
163[rule.threat_filters.meta]
164disabled = false
165key = "event.type"
166negate = false
167type = "phrase"
168[rule.threat_filters.meta.params]
169query = "indicator"
170[rule.threat_filters.query.match_phrase]
171"event.type" = "indicator"
172[[rule.threat_mapping]]
173
174[[rule.threat_mapping.entries]]
175field = "file.hash.md5"
176type = "mapping"
177value = "threat.indicator.file.hash.md5"
178
179[[rule.threat_mapping]]
180
181[[rule.threat_mapping.entries]]
182field = "file.hash.sha1"
183type = "mapping"
184value = "threat.indicator.file.hash.sha1"
185
186[[rule.threat_mapping]]
187
188[[rule.threat_mapping.entries]]
189field = "file.hash.sha256"
190type = "mapping"
191value = "threat.indicator.file.hash.sha256"
192
193[[rule.threat_mapping]]
194
195[[rule.threat_mapping.entries]]
196field = "dll.hash.md5"
197type = "mapping"
198value = "threat.indicator.file.hash.md5"
199
200[[rule.threat_mapping]]
201
202[[rule.threat_mapping.entries]]
203field = "dll.hash.sha1"
204type = "mapping"
205value = "threat.indicator.file.hash.sha1"
206
207[[rule.threat_mapping]]
208
209[[rule.threat_mapping.entries]]
210field = "dll.hash.sha256"
211type = "mapping"
212value = "threat.indicator.file.hash.sha256"
213
214[[rule.threat_mapping]]
215
216[[rule.threat_mapping.entries]]
217field = "process.hash.md5"
218type = "mapping"
219value = "threat.indicator.file.hash.md5"
220
221[[rule.threat_mapping]]
222
223[[rule.threat_mapping.entries]]
224field = "process.hash.sha1"
225type = "mapping"
226value = "threat.indicator.file.hash.sha1"
227
228[[rule.threat_mapping]]
229
230[[rule.threat_mapping.entries]]
231field = "process.hash.sha256"
232type = "mapping"
233value = "threat.indicator.file.hash.sha256"

Triage and Analysis

Investigating Threat Intel Hash Indicator Match

Threat Intel indicator match rules allow matching from a local observation, such as an endpoint event that records a file hash with an entry of a file hash stored within the Threat Intel integrations index.

Matches are based on threat intelligence data that's been ingested during the last 30 days. Some integrations don't place expiration dates on their threat indicators, so we strongly recommend validating ingested threat indicators and reviewing match results. When reviewing match results, check associated activity to determine whether the event requires additional investigation.

This rule is triggered when a hash indicator from the Threat Intel Filebeat module or an indicator ingested from a threat intelligence integration matches against an event that contains file hashes, such as antivirus alerts, file operation events, etc.

Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.

Possible investigation steps

  • Gain context about the field that matched the local observation. This information can be found in the threat.indicator.matched.field field.
  • Investigate the hash , which can be found in the threat.indicator.matched.atomic field:
    • Search for the existence and reputation of the hash in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
    • Scope other potentially compromised hosts in your environment by mapping hosts with file operations involving the same hash.
  • Identify the process that created the file.
    • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
    • Enrich the information that you have right now by determining how the file was dropped, where it was downloaded from, etc. This can help you determine if the event is part of an ongoing campaign against the organization.
  • Retrieve the involved file and examine the host for derived artifacts that indicate suspicious activities:
    • Analyze the process executable using a private sandboxed analysis system.
    • Observe and collect information about the following activities in both the sandbox and the alert subject host:
      • Attempts to contact external domains and addresses.
        • Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' process.entity_id.
        • Examine the DNS cache for suspicious or anomalous entries.
          • $osquery_0
      • Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
      • Examine the host services for suspicious or anomalous entries.
        • $osquery_1
        • $osquery_2
        • $osquery_3
  • Using the data collected through the analysis, scope users targeted and other machines infected in the environment.

False Positive Analysis

  • Adversaries often use legitimate tools as network administrators, such as PsExec or AdFind. These tools are often included in indicator lists, which creates the potential for false positives.

Response and Remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • If the triage identified malware, search the environment for additional compromised hosts.
    • Implement temporary network rules, procedures, and segmentation to contain the malware.
    • Stop suspicious processes.
    • Immediately block the identified indicators of compromise (IoCs).
    • Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
  • Remove and block malicious artifacts identified during triage.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top