Masquerading Space After Filename

This rules identifies a process created from an executable with a space appended to the end of the filename. This may indicate an attempt to masquerade a malicious file as benign to gain user execution. When a space is added to the end of certain files, the OS will execute the file according to it's true filetype instead of it's extension. Adversaries can hide a program's true filetype by changing the extension of the file. They can then add a space to the end of the name so that the OS automatically executes the file when it's double-clicked.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/10/18"
 3integration = ["endpoint"]
 4maturity = "production"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2023/06/22"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12This rules identifies a process created from an executable with a space appended to the end of the filename. This may
13indicate an attempt to masquerade a malicious file as benign to gain user execution. When a space is added to the end of
14certain files, the OS will execute the file according to it's true filetype instead of it's extension. Adversaries can
15hide a program's true filetype by changing the extension of the file. They can then add a space to the end of the name
16so that the OS automatically executes the file when it's double-clicked.
17"""
18from = "now-9m"
19index = ["auditbeat-*", "logs-endpoint.events.*"]
20language = "eql"
21license = "Elastic License v2"
22name = "Masquerading Space After Filename"
23note = """## Setup
24
25If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define `event.ingested` and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate `event.ingested` to @timestamp for this rule to work.
26"""
27references = [
28    "https://www.picussecurity.com/resource/blog/picus-10-critical-mitre-attck-techniques-t1036-masquerading",
29]
30risk_score = 47
31rule_id = "f5fb4598-4f10-11ed-bdc3-0242ac120002"
32severity = "medium"
33tags = ["Domain: Endpoint", "OS: Linux", "OS: macOS", "Use Case: Threat Detection", "Tactic: Defense Evasion", "Data Source: Elastic Defend"]
34timestamp_override = "event.ingested"
35type = "eql"
36
37query = '''
38process where host.os.type:("linux","macos") and
39  event.type == "start" and
40  (process.executable regex~ """/[a-z0-9\s_\-\\./]+\s""") and not
41  process.name in ("ls", "find", "grep", "xkbcomp")
42'''
43
44
45[[rule.threat]]
46framework = "MITRE ATT&CK"
47[[rule.threat.technique]]
48id = "T1036"
49name = "Masquerading"
50reference = "https://attack.mitre.org/techniques/T1036/"
51[[rule.threat.technique.subtechnique]]
52id = "T1036.006"
53name = "Space after Filename"
54reference = "https://attack.mitre.org/techniques/T1036/006/"
55
56
57
58[rule.threat.tactic]
59id = "TA0005"
60name = "Defense Evasion"
61reference = "https://attack.mitre.org/tactics/TA0005/"

Setup

If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define event.ingested and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate event.ingested to @timestamp for this rule to work.

References

Related rules

to-top