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