Detection rules › Elastic
Linux Background Process Execution via Shell
Detects when a binary located in a suspicious location gets executed by a shell interpreter and put in the background via the & operator. Malware may execute their payloads in the background in an effort to remain hidden.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
Rule body
[rule]
description = """
Detects when a binary located in a suspicious location gets executed by a shell interpreter and put in the background
via the & operator. Malware may execute their payloads in the background in an effort to remain hidden.
"""
id = "21692d53-d4a5-462c-9ee6-2d8788411996"
license = "Elastic License v2"
name = "Linux Background Process Execution via Shell"
os_list = ["linux"]
version = "1.0.8"
query = '''
process where event.type == "start" and event.action == "exec" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and process.args == "-c" and
process.args like ("/* &", "/*&") and process.args_count == 3 and
process.parent.executable like ("/dev/shm/*", "/var/tmp/*", "/tmp/*", "/var/www/*") and
not (
process.executable like "/tmp/newroot/*" or
process.command_line == "/bin/bash -c /opt/forticlient/fortitray &" or
process.parent.executable like ("/var/www/splynx/*", "/tmp/.mount_cursor*", "/tmp/newroot/*") or
process.parent.args == "cursor"
)
'''
min_endpoint_version = "7.15.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 = "7.15.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and process.args == "-c" and
process.args like ("/* &", "/*&") and process.args_count == 3 and
process.parent.executable like ("/dev/shm/*", "/var/tmp/*", "/tmp/*", "/var/www/*") and
not (
process.executable like "/tmp/newroot/*" or
process.command_line == "/bin/bash -c /opt/forticlient/fortitray &" or
process.parent.executable like ("/var/www/splynx/*", "/tmp/.mount_cursor*", "/tmp/newroot/*") or
process.parent.args == "cursor"
)
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.command_line | eq | /bin/bash -c /opt/forticlient/fortitray & | excludes:process.command_line field:"process.command_line" value:"/bin/bash -c /opt/forticlient/fortitray &" |
process.executable | starts_with | /tmp/newroot/ | excludes:process.executable field:"process.executable" value:"/tmp/newroot/" |
process.parent.args | eq | cursor | excludes:process.parent.args field:"process.parent.args" value:"cursor" |
process.parent.executable | starts_with | /var/www/splynx/, /tmp/.mount_cursor, /tmp/newroot/ | excludes:process.parent.executable field:"process.parent.executable" value:"/var/www/splynx/" field:"process.parent.executable" value:"/tmp/.mount_cursor" field:"process.parent.executable" value:"/tmp/newroot/" |
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:"3" |
process.name | in |
| field:"process_name" kind:in |
process.parent.executable | wildcard |
| field:"ParentImage" kind:wildcard |