Detection rules › Elastic
Suspicious Child Process Execution via Interactive Shell
Detects when a process is executed via an interactive shell. C2 platforms will commonly spawn an interactive shell providing the threat actor with a remote shell on the system as if they were physically at the terminal allowing them to send and execute commands manually.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Telemetry coverage
Rule body
[rule]
description = """
Detects when a process is executed via an interactive shell. C2 platforms will commonly spawn an interactive shell
providing the threat actor with a remote shell on the system as if they were physically at the terminal allowing them to
send and execute commands manually.
"""
id = "f10a679a-c266-494f-b3aa-53830949d288"
license = "Elastic License v2"
name = "Suspicious Child Process Execution via Interactive Shell"
os_list = ["macos"]
version = "1.0.22"
query = '''
sequence by process.Ext.effective_parent.entity_id with maxspan=1m
[process where event.type == "start" and event.action == "exec" and (process.name in ("zsh", "bash", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and
process.args == "-i" and process.args_count <= 2 and
process.parent.name like~ ("osascript", "python*", "node")]
[process where event.type == "start" and event.action == "exec" and
process.name like~ ("curl", "whoami", "pwd", "nscurl", "wget", "dscl", "osascript", ".*") and
not process.args like~ ("SendEnv=GIT_PROTOCOL", "-V", "--version", "-ss", "localhost*") and
not process.parent.executable like~
("/Library/Developer/CommandLineTools/usr/bin/git",
"/Users/*/.pyenv/*",
"/Users/*/.nvm/*",
"/Applications/Docker.app/Contents/Resources/bin/docker-credential-desktop",
"/Applications/Xcode.app/Contents/Developer/usr/bin/git",
"/opt/homebrew/*") and
not (process.parent.command_line like "bash /Users/*/.claude/statusline-command.sh" and
process.Ext.effective_parent.executable == "/Applications/Visual Studio Code.app/Contents/MacOS/Code")]
'''
min_endpoint_version = "8.7.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.7.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1m, correlated by process.Ext.effective_parent.entity_id.
Stage 1: process
[process where event.type == "start" and event.action == "exec" and (process.name in ("zsh", "bash", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and
process.args == "-i" and process.args_count <= 2 and
process.parent.name like~ ("osascript", "python*", "node")]
Stage 2: process
[process where event.type == "start" and event.action == "exec" and
process.name like~ ("curl", "whoami", "pwd", "nscurl", "wget", "dscl", "osascript", ".*") and
not process.args like~ ("SendEnv=GIT_PROTOCOL", "-V", "--version", "-ss", "localhost*") and
not process.parent.executable like~
("/Library/Developer/CommandLineTools/usr/bin/git",
"/Users/*/.pyenv/*",
"/Users/*/.nvm/*",
"/Applications/Docker.app/Contents/Resources/bin/docker-credential-desktop",
"/Applications/Xcode.app/Contents/Developer/usr/bin/git",
"/opt/homebrew/*") and
not (process.parent.command_line like "bash /Users/*/.claude/statusline-command.sh" and
process.Ext.effective_parent.executable == "/Applications/Visual Studio Code.app/Contents/MacOS/Code")]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | eq | /Applications/Visual Studio Code.app/Contents/MacOS/Code | excludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"/Applications/Visual Studio Code.app/Contents/MacOS/Code" |
process.parent.command_line | wildcard | bash /Users/*/.claude/statusline-command.sh | excludes:process.parent.command_line field:"process.parent.command_line" value:"bash /Users/*/.claude/statusline-command.sh" |
process.args | wildcard | SendEnv=GIT_PROTOCOL, -V, --version, -ss, localhost* | excludes:process.args |
process.parent.executable | wildcard | /Library/Developer/CommandLineTools/usr/bin/git, /Users/*/.pyenv/*, /Users/*/.nvm/*, /Applications/Docker.app/Contents/Resources/bin/docker-credential-desktop, /Applications/Xcode.app/Contents/Developer/usr/bin/git, /opt/homebrew/* | excludes:process.parent.executable |
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:"-i" |
process.args_count | le |
| field:"process.args_count" kind:le value:"2" |
process.name | in |
| field:"process_name" kind:in |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard |