Detection rules › Elastic
Potential Self Deletion of a Running Executable
Identifies the execution of a file followed by the rename of its primary file stream. This may indicate an attempt to delete the currently running process executable file on disk, bypassing the file lock restriction. Adversaries may delete files left behind by the actions of their intrusion activity.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = """
Identifies the execution of a file followed by the rename of its primary file stream. This may indicate an attempt to
delete the currently running process executable file on disk, bypassing the file lock restriction. Adversaries may
delete files left behind by the actions of their intrusion activity.
"""
id = "24082642-49a7-4072-952b-10c244b24f8e"
license = "Elastic License v2"
name = "Potential Self Deletion of a Running Executable"
os_list = ["windows"]
reference = [
"https://github.com/LloydLabs/delete-self-poc",
"https://www.elastic.co/security-labs/spring-cleaning-with-latrodectus",
]
version = "1.0.34"
query = '''
sequence by process.entity_id with maxspan=1m
[library where not dll.code_signature.status : "trusted" and
not (process.code_signature.subject_name: ("Datto Inc", "Elasticsearch, Inc.") and process.code_signature.trusted == true)] by dll.name
[file where event.action == "rename" and
/* Rename the primary file stream */
file.name : "*:*" and not file.Ext.original.name : "*:*" and file.size == 0] by file.Ext.original.name
'''
min_endpoint_version = "8.0.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1070"
name = "Indicator Removal"
reference = "https://attack.mitre.org/techniques/T1070/"
[[threat.technique.subtechnique]]
id = "T1070.004"
name = "File Deletion"
reference = "https://attack.mitre.org/techniques/T1070/004/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.0.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1m, correlated by dll.name, file.Ext.original.name, process.entity_id.
Stage 1: library
[library where not dll.code_signature.status : "trusted" and
not (process.code_signature.subject_name: ("Datto Inc", "Elasticsearch, Inc.") and process.code_signature.trusted == true)] by dll.name
Stage 2: file
[file where event.action == "rename" and
file.name : "*:*" and not file.Ext.original.name : "*:*" and file.size == 0] by file.Ext.original.name
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.code_signature.subject_name | eq | Datto Inc, Elasticsearch, Inc. | excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Datto Inc" field:"process.code_signature.subject_name" value:"Elasticsearch, Inc." |
process.code_signature.trusted | eq | true | excludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true" |
dll.code_signature.status | eq | trusted | excludes:dll.code_signature.status field:"dll.code_signature.status" value:"trusted" |
file.Ext.original.name | match | : | excludes:file.Ext.original.name field:"file.Ext.original.name" value:":" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"rename" |
file.name | wildcard |
| field:"file.name" kind:wildcard value:"*:*" |
file.size | eq |
| field:"file.size" kind:eq value:"0" |