Detection rules › Elastic
Suspicious Perl Child Process Execution
Detects when Perl executes suspicious child processes on macOS. Perl can be abused by adversaries to execute malicious commands or scripts.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Telemetry coverage
Rule body
[rule]
description = """
Detects when Perl executes suspicious child processes on macOS. Perl can be abused by adversaries to execute malicious
commands or scripts.
"""
id = "45681609-ac5b-4151-9014-204590e87e1d"
license = "Elastic License v2"
name = "Suspicious Perl Child Process Execution"
os_list = ["macos"]
version = "1.0.5"
query = '''
process where event.type == "start" and event.action == "exec" and process.parent.name == "perl" and
(process.name like~ ("python*", "curl", "nscurl", "osascript", "whoami", "cat", "Terminal") or
(process.name in ("sh", "zsh", "bash") and process.args_count == 2 and process.args == "-c" and process.args like ("/Users/*", "/tmp/*", "/private/tmp/*"))) and
not process.parent.command_line like "perl /Library/TeX/texbin/tlmgr*" and
not process.Ext.effective_parent.executable like ("/System/*", "/Applications/Xcode.app/Contents/MacOS/Xcode")
'''
min_endpoint_version = "8.16.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 = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.004"
name = "Unix Shell"
reference = "https://attack.mitre.org/techniques/T1059/004/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[internal]
min_endpoint_version = "8.16.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and process.parent.name == "perl" and
(process.name like~ ("python*", "curl", "nscurl", "osascript", "whoami", "cat", "Terminal") or
(process.name in ("sh", "zsh", "bash") and process.args_count == 2 and process.args == "-c" and process.args like ("/Users/*", "/tmp/*", "/private/tmp/*"))) and
not process.parent.command_line like "perl /Library/TeX/texbin/tlmgr*" and
not process.Ext.effective_parent.executable like ("/System/*", "/Applications/Xcode.app/Contents/MacOS/Xcode")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | wildcard | /System/*, /Applications/Xcode.app/Contents/MacOS/Xcode | excludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"/System/*" field:"process.Ext.effective_parent.executable" value:"/Applications/Xcode.app/Contents/MacOS/Xcode" |
process.parent.command_line | starts_with | perl /Library/TeX/texbin/tlmgr | excludes:process.parent.command_line field:"process.parent.command_line" value:"perl /Library/TeX/texbin/tlmgr" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | eq |
| field:"process.args" kind:eq value:"-c" |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.args_count | eq |
| field:"process.args_count" kind:eq value:"2" |
process.name | in |
| field:"process_name" kind:in |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.name | eq |
| field:"parent_process_name" kind:eq value:"perl" |