Detection rules › Elastic
File Made Executable via Package Install Script
Detects when a file in a suspicious file path is made executable via the chmod binary immediately after an installer pkg is executed via the postinstall script. This is not a common occurrence and indicates the installation of a malicious binary.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Telemetry coverage
Rule body
[rule]
description = """
Detects when a file in a suspicious file path is made executable via the chmod binary immediately after an installer pkg
is executed via the postinstall script. This is not a common occurrence and indicates the installation of a malicious
binary.
"""
id = "75f5d51a-218f-4d5b-80e5-eb74e498fde4"
license = "Elastic License v2"
name = "File Made Executable via Package Install Script"
os_list = ["macos"]
version = "1.0.27"
query = '''
sequence by process.parent.pid with maxspan=30s
[process where event.type == "start" and event.action == "fork" and
process.name like~ ("bash", "zsh", "sh", "python*", "tclsh*", "dash", "csh", "tcsh", "ksh", "fish") and
process.args like~ "/tmp/PKInstallSandbox.*/Scripts/*/postinstall" and
process.args like ("/Users/*", "/Volumes/*") and
not process.args like "/Applications/Adobe Acrobat DC"]
[process where event.type == "start" and event.action == "exec" and
process.name == "chmod" and
process.args in ("+x", "a+x", "0777", "777") and
process.args like~ ("/private/tmp/*",
"/var/tmp/*",
"/var/lib/*",
"/tmp/*",
"/var/folders/*",
"/Users/Shared/*",
"/Library/Containers/*",
"/Users/*/Library/*",
"/Users/*/Applications/*",
"/var/root/*",
"/Library/WebServer/*",
"/Library/Fonts/*",
"/usr/local/bin/*") and
process.parent.name like~ ("bash", "zsh", "sh", "python*", "tclsh*", "osascript", "dash", "csh", "tcsh", "ksh", "fish") and not
process.command_line == "chmod +x decompress"]
'''
min_endpoint_version = "8.11.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1222"
name = "File and Directory Permissions Modification"
reference = "https://attack.mitre.org/techniques/T1222/"
[[threat.technique.subtechnique]]
id = "T1222.002"
name = "Linux and Mac File and Directory Permissions Modification"
reference = "https://attack.mitre.org/techniques/T1222/002/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.11.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 30s, correlated by process.parent.pid.
Stage 1: process
[process where event.type == "start" and event.action == "fork" and
process.name like~ ("bash", "zsh", "sh", "python*", "tclsh*", "dash", "csh", "tcsh", "ksh", "fish") and
process.args like~ "/tmp/PKInstallSandbox.*/Scripts/*/postinstall" and
process.args like ("/Users/*", "/Volumes/*") and
not process.args like "/Applications/Adobe Acrobat DC"]
Stage 2: process
[process where event.type == "start" and event.action == "exec" and
process.name == "chmod" and
process.args in ("+x", "a+x", "0777", "777") and
process.args like~ ("/private/tmp/*",
"/var/tmp/*",
"/var/lib/*",
"/tmp/*",
"/var/folders/*",
"/Users/Shared/*",
"/Library/Containers/*",
"/Users/*/Library/*",
"/Users/*/Applications/*",
"/var/root/*",
"/Library/WebServer/*",
"/Library/Fonts/*",
"/usr/local/bin/*") and
process.parent.name like~ ("bash", "zsh", "sh", "python*", "tclsh*", "osascript", "dash", "csh", "tcsh", "ksh", "fish") and not
process.command_line == "chmod +x decompress"]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | /Applications/Adobe Acrobat DC | excludes:process.args field:"process.args" value:"/Applications/Adobe Acrobat DC" |
process.command_line | eq | chmod +x decompress | excludes:process.command_line field:"process.command_line" value:"chmod +x decompress" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | in |
| field:"process.args" kind:in |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.name | eq |
| field:"process_name" kind:eq value:"chmod" |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard |