Detection rules › Elastic
Shell Command Curl Execution via Osascript
Detects osascript spawning shell interpreters to execute curl commands within 15 seconds. This pattern indicates malicious AppleScript workflows used for payload downloads or C2 communication.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Command & Control |
Telemetry coverage
Rule body
[rule]
description = """
Detects osascript spawning shell interpreters to execute curl commands within 15 seconds. This pattern indicates
malicious AppleScript workflows used for payload downloads or C2 communication.
"""
id = "92840250-1d07-4e8b-9a72-d2ed03dc6bc6"
license = "Elastic License v2"
name = "Shell Command Curl Execution via Osascript"
os_list = ["macos"]
version = "1.0.3"
query = '''
sequence by process.parent.entity_id with maxspan=15s
[process where event.type == "start" and event.action == "exec" and process.args == "-c" and process.name in ("bash", "sh", "zsh") and process.parent.name == "osascript"]
[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl")]
'''
min_endpoint_version = "8.16.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.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.002"
name = "AppleScript"
reference = "https://attack.mitre.org/techniques/T1059/002/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1105"
name = "Ingress Tool Transfer"
reference = "https://attack.mitre.org/techniques/T1105/"
[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"
[internal]
min_endpoint_version = "8.16.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 15s, correlated by process.parent.entity_id.
Stage 1: process
[process where event.type == "start" and event.action == "exec" and process.args == "-c" and process.name in ("bash", "sh", "zsh") and process.parent.name == "osascript"]
Stage 2: process
[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl")]
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.name | in |
| field:"process_name" kind:in |
process.parent.name | eq |
| field:"parent_process_name" kind:eq value:"osascript" |