Detection rules › Elastic

Potential Privilege Escalation via a Known SUID/SGID Binary

Source
github.com/elastic/protections-artifacts

This rule detects potential local privilege escalation attempts via known, pre-installed SUID/SGID binaries. Attackers may abuse SUID/SGID binaries to escalate their privileges to root, using exploits or misconfigurations.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
This rule detects potential local privilege escalation attempts via known, pre-installed SUID/SGID binaries. Attackers
may abuse SUID/SGID binaries to escalate their privileges to root, using exploits or misconfigurations.
"""
id = "b1d415dc-796a-48f1-944f-4bb6037b2450"
license = "Elastic License v2"
name = "Potential Privilege Escalation via a Known SUID/SGID Binary"
os_list = ["linux"]
version = "1.0.3"

query = '''
process where event.type == "start" and event.action == "exec" and (
  (process.user.id == 0 and process.real_user.id != 0 and process.parent.user.id != 0) or
  (process.group.id == 0 and process.real_group.id != 0 and process.parent.group.id != 0)
) and
(
  (process.name == "unix_chkpwd" and process.args_count <= 2) or
  (
    process.name in ("fusermount", "fusermount3", "umount", "newgrp", "chsh") and
    process.args_count == 1
  ) or
  process.name in (
    "sudoedit", "gpasswd", "chfn", "polkit-agent-helper-1", "dbus-daemon-launch-helper", "ssh-keysign",
    "pam_extrausers_chkpwd", "expiry", "chage", "wall", "bsd-write", "ssh-agent",
    "ping6", "traceroute", "mtr", "ntfs-3g", "chrome-sandbox"
  )
) and
(
  process.parent.name like (".*", "python*", "perl*", "ruby*", "lua*", "php*", "node", "deno", "bun", "java") or
  process.parent.executable like ("./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/user/*", "/var/run/user/*", "/home/*/*") or
  (
    process.parent.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "mksh") and
    process.parent.args in ("-c", "-cl", "-lc", "--command", "-ic", "-ci", "-bash", "-sh", "-zsh", "-dash", "-fish", "-ksh", "-mksh") and
    process.parent.args_count <= 4
  )
) and
not (
  (process.name == "chage" and process.args == "-l" and process.args_count == 3) or
  (
    process.name == "sudoedit" and (
      (process.args == "-s" and process.args == "/") or
      process.args in ("--help", "-h") or
      process.args like "AAAAAA*"
    )
  ) or
  (process.name == "traceroute" and process.args_count == 2) or
  (process.executable == "/usr/bin/umount" and process.command_line == "umount") or
  process.executable like ("/tmp/newroot/*/chrome-sandbox", "/home/*/chrome-sandbox", "/tmp/newroot/usr/lib/polkit-1/polkit-agent-helper-1", "/opt/brave.com/brave/chrome-sandbox")
)
'''

min_endpoint_version = "8.2.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 = "T1068"
name = "Exploitation for Privilege Escalation"
reference = "https://attack.mitre.org/techniques/T1068/"

[[threat.technique]]
id = "T1548"
name = "Abuse Elevation Control Mechanism"
reference = "https://attack.mitre.org/techniques/T1548/"
[[threat.technique.subtechnique]]
id = "T1548.001"
name = "Setuid and Setgid"
reference = "https://attack.mitre.org/techniques/T1548/001/"

[[threat.technique.subtechnique]]
id = "T1548.003"
name = "Sudo and Sudo Caching"
reference = "https://attack.mitre.org/techniques/T1548/003/"



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

[internal]
min_endpoint_version = "8.2.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and event.action == "exec" and (
  (process.user.id == 0 and process.real_user.id != 0 and process.parent.user.id != 0) or
  (process.group.id == 0 and process.real_group.id != 0 and process.parent.group.id != 0)
) and
(
  (process.name == "unix_chkpwd" and process.args_count <= 2) or
  (
    process.name in ("fusermount", "fusermount3", "umount", "newgrp", "chsh") and
    process.args_count == 1
  ) or
  process.name in (
    "sudoedit", "gpasswd", "chfn", "polkit-agent-helper-1", "dbus-daemon-launch-helper", "ssh-keysign",
    "pam_extrausers_chkpwd", "expiry", "chage", "wall", "bsd-write", "ssh-agent",
    "ping6", "traceroute", "mtr", "ntfs-3g", "chrome-sandbox"
  )
) and
(
  process.parent.name like (".*", "python*", "perl*", "ruby*", "lua*", "php*", "node", "deno", "bun", "java") or
  process.parent.executable like ("./*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/user/*", "/var/run/user/*", "/home/*/*") or
  (
    process.parent.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "mksh") and
    process.parent.args in ("-c", "-cl", "-lc", "--command", "-ic", "-ci", "-bash", "-sh", "-zsh", "-dash", "-fish", "-ksh", "-mksh") and
    process.parent.args_count <= 4
  )
) and
not (
  (process.name == "chage" and process.args == "-l" and process.args_count == 3) or
  (
    process.name == "sudoedit" and (
      (process.args == "-s" and process.args == "/") or
      process.args in ("--help", "-h") or
      process.args like "AAAAAA*"
    )
  ) or
  (process.name == "traceroute" and process.args_count == 2) or
  (process.executable == "/usr/bin/umount" and process.command_line == "umount") or
  process.executable like ("/tmp/newroot/*/chrome-sandbox", "/home/*/chrome-sandbox", "/tmp/newroot/usr/lib/polkit-1/polkit-agent-helper-1", "/opt/brave.com/brave/chrome-sandbox")
)

Exclusions

The rule actively suppresses these predicates.

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • exec
field:"EventType" kind:eq value:"exec"
event.typeeq
  • start
field:"event.type" kind:eq value:"start"
process.args_counteq
  • 1 transforms: number
field:"process.args_count" kind:eq value:"1"
process.args_countle
  • 2 transforms: number
field:"process.args_count" kind:le value:"2"
process.group.ideq
  • 0 transforms: number
field:"process.group.id" kind:eq value:"0"
process.nameeq
  • unix_chkpwd
field:"process_name" kind:eq value:"unix_chkpwd"
process.namein
  • bsd-write
  • chage
  • chfn
  • chrome-sandbox
  • chsh
  • dbus-daemon-launch-helper
  • expiry
  • fusermount
  • fusermount3
  • gpasswd
  • mtr
  • newgrp
  • ntfs-3g
  • pam_extrausers_chkpwd
  • ping6
  • polkit-agent-helper-1
  • ssh-agent
  • ssh-keysign
  • sudoedit
  • traceroute
  • umount
  • wall
field:"process_name" kind:in
process.parent.argsin
  • --command
  • -bash
  • -c
  • -ci
  • -cl
  • -dash
  • -fish
  • -ic
  • -ksh
  • -lc
  • -mksh
  • -sh
  • -zsh
field:"process.parent.args" kind:in
process.parent.args_countle
  • 4 transforms: number
field:"process.parent.args_count" kind:le value:"4"
process.parent.executablewildcard
  • ./*
  • /dev/shm/*
  • /home/*/*
  • /run/user/*
  • /tmp/*
  • /var/run/user/*
  • /var/tmp/*
field:"ParentImage" kind:wildcard
process.parent.group.idne
  • 0 transforms: number
field:"process.parent.group.id" kind:ne value:"0"
process.parent.namein
  • bash
  • csh
  • dash
  • fish
  • ksh
  • mksh
  • sh
  • tcsh
  • zsh
field:"parent_process_name" kind:in
process.parent.namewildcard
  • .*
  • bun
  • deno
  • java
  • lua*
  • node
  • perl*
  • php*
  • python*
  • ruby*
field:"parent_process_name" kind:wildcard
process.parent.user.idne
  • 0 transforms: number
field:"process.parent.user.id" kind:ne value:"0"
process.real_group.idne
  • 0 transforms: number
field:"process.real_group.id" kind:ne value:"0"
process.real_user.idne
  • 0 transforms: number
field:"process.real_user.id" kind:ne value:"0"
process.user.ideq
  • 0 transforms: number
field:"process.user.id" kind:eq value:"0"