Detection rules › Elastic

File Made Executable via Package Install Script

Time window
30s
Sequence by
process.parent.pid
Source
github.com/elastic/protections-artifacts

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

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.

FieldKindExcluded valuesSearch
process.argseq/Applications/Adobe Acrobat DCexcludes:process.args field:"process.args" value:"/Applications/Adobe Acrobat DC"
process.command_lineeqchmod +x decompressexcludes:process.command_line field:"process.command_line" value:"chmod +x decompress"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • exec
  • fork
field:"EventType" kind:eq
event.typeeq
  • start
field:"event.type" kind:eq value:"start"
process.argsin
  • +x
  • 0777
  • 777
  • a+x
field:"process.args" kind:in
process.argswildcard
  • /Library/Containers/*
  • /Library/Fonts/*
  • /Library/WebServer/*
  • /Users/*
  • /Users/*/Applications/*
  • /Users/*/Library/*
  • /Users/Shared/*
  • /Volumes/*
  • /private/tmp/*
  • /tmp/*
  • /tmp/PKInstallSandbox.*/Scripts/*/postinstall
  • /usr/local/bin/*
  • /var/folders/*
  • /var/lib/*
  • /var/root/*
  • /var/tmp/*
field:"process.args" kind:wildcard
process.nameeq
  • chmod
field:"process_name" kind:eq value:"chmod"
process.namewildcard
  • bash
  • csh
  • dash
  • fish
  • ksh
  • python*
  • sh
  • tclsh*
  • tcsh
  • zsh
field:"process_name" kind:wildcard
process.parent.namewildcard
  • bash
  • csh
  • dash
  • fish
  • ksh
  • osascript
  • python*
  • sh
  • tclsh*
  • tcsh
  • zsh
field:"parent_process_name" kind:wildcard