Detection rules › Elastic

General Privilege Escalation Sequence Detected

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

This rule detects the execution of a binary, followed by a UID change event to 0 (root), and then the execution of a command that is used to check the current user's privileges. This sequence is often used by exploits to escalate privileges to root, and check if the escalation was successful.

MITRE ATT&CK coverage

TacticTechniques
Privilege Escalation

Rule body

[rule]
description = """
This rule detects the execution of a binary, followed by a UID change event to 0 (root), and then the execution of a
command that is used to check the current user's privileges. This sequence is often used by exploits to escalate
privileges to root, and check if the escalation was successful.
"""
id = "d8194360-9d84-43fb-bd8a-51db153d6632"
license = "Elastic License v2"
name = "General Privilege Escalation Sequence Detected"
os_list = ["linux"]
version = "1.0.6"

query = '''
sequence with maxspan=10s
  [process where event.type == "start" and event.action == "exec" and user.id != 0 and
   process.executable like ("/tmp/*", "/dev/shm/*", "/var/tmp/*", "/home/*", "/run/user/*", "/var/run/user/*") and
   not process.parent.executable in ("/usr/bin/sw-engine", "/usr/sbin/sshd", "/usr/sbin/sw-engine-fpm", "/usr/lib/systemd/systemd")] by process.entity_id
  [process where event.type == "change" and event.action == "uid_change" and user.id == 0] by process.entity_id
  [process where event.type == "start" and event.action == "exec" and process.name in ("whoami", "id", "logname") and user.id == 0] by process.parent.entity_id
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

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

[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 2

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 1

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 2

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1068"
name = "Exploitation for Privilege Escalation"
reference = "https://attack.mitre.org/techniques/T1068/"


[threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

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

Stage 1: process

[process where event.type == "start" and event.action == "exec" and user.id != 0 and
   process.executable like ("/tmp/*", "/dev/shm/*", "/var/tmp/*", "/home/*", "/run/user/*", "/var/run/user/*") and
   not process.parent.executable in ("/usr/bin/sw-engine", "/usr/sbin/sshd", "/usr/sbin/sw-engine-fpm", "/usr/lib/systemd/systemd")] by process.entity_id

Stage 2: process

[process where event.type == "change" and event.action == "uid_change" and user.id == 0] by process.entity_id

Stage 3: process

[process where event.type == "start" and event.action == "exec" and process.name in ("whoami", "id", "logname") and user.id == 0] by process.parent.entity_id

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.parent.executablein/usr/bin/sw-engine, /usr/lib/systemd/systemd, /usr/sbin/sshd, /usr/sbin/sw-engine-fpmexcludes:process.parent.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • exec
  • uid_change
field:"EventType" kind:eq
event.typeeq
  • change
  • start
field:"event.type" kind:eq
process.executablewildcard
  • /dev/shm/*
  • /home/*
  • /run/user/*
  • /tmp/*
  • /var/run/user/*
  • /var/tmp/*
field:"Image" kind:wildcard
process.namein
  • id
  • logname
  • whoami
field:"process_name" kind:in
user.ideq
  • 0 transforms: number
field:"user.id" kind:eq value:"0"
user.idne
  • 0 transforms: number
field:"user.id" kind:ne value:"0"