Detection rules › Elastic

Suspicious Execution of Unsigned or Untrusted Process via Sudo

Time window
5s
Sequence by
process.entity_id, process.parent.entity_id
Source
github.com/elastic/protections-artifacts

Detects when Sudo is used to execute an untrusted or unsigned binary via the -S option allowing a password or pre-gathered key to be piped to the binary upon execution. A recent stealer sample was seen executing a second stage payload in this manner passing the user provided password to supply the second stage payload with upon execution. The use of Sudo with the -S option in itself is not common but when its used to execute an untrusted or unsigned binary it should be considered highly suspicious acitvity.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

[rule]
description = """
Detects when Sudo is used to execute an untrusted or unsigned binary via the -S option allowing a password or
pre-gathered key to be piped to the binary upon execution. A recent stealer sample was seen executing a second stage
payload in this manner passing the user provided password to supply the second stage payload with upon execution. The
use of Sudo with the -S option in itself is not common but when its used to execute an untrusted or unsigned binary it
should be considered highly suspicious acitvity.
"""
id = "7998fa77-dc94-4bd7-b458-34cf1cbcee9a"
license = "Elastic License v2"
name = "Suspicious Execution of Unsigned or Untrusted Process via Sudo"
os_list = ["macos"]
reference = ["https://x.com/moonlock_lab/status/1815640547551306015"]
version = "1.0.6"

query = '''
sequence with maxspan=5s
[process where event.type == "start" and event.action == "exec" and process.name == "sudo" and 
  process.args == "-S"] by process.entity_id
[process where event.type == "start" and event.action == "exec" and process.parent.name == "sudo" and 
  (process.code_signature.trusted == false or process.code_signature.exists == false)] by process.parent.entity_id
'''

min_endpoint_version = "8.11.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[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.11.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 5s, correlated by process.entity_id, process.parent.entity_id.

Stage 1: process

[process where event.type == "start" and event.action == "exec" and process.name == "sudo" and 
  process.args == "-S"] by process.entity_id

Stage 2: process

[process where event.type == "start" and event.action == "exec" and process.parent.name == "sudo" and 
  (process.code_signature.trusted == false or process.code_signature.exists == false)] by process.parent.entity_id

Indicators

These rows show field, operator, and value matches.