Privilege Escalation via SUID/SGID
Identifies instances where a process is executed with user/group ID 0 (root), and a real user/group ID that is not 0. This is indicative of a process that has been granted SUID/SGID permissions, allowing it to run with elevated privileges. Attackers may leverage a misconfiguration for exploitation in order to escalate their privileges to root, or establish a backdoor for persistence.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/17"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/06/17"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies instances where a process is executed with user/group ID 0 (root), and a real user/group ID that is not 0.
11This is indicative of a process that has been granted SUID/SGID permissions, allowing it to run with elevated
12privileges. Attackers may leverage a misconfiguration for exploitation in order to escalate their privileges to root, or
13establish a backdoor for persistence.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Privilege Escalation via SUID/SGID"
20references = ["https://gtfobins.github.io/#+suid"]
21risk_score = 47
22rule_id = "28eb3afe-131d-48b0-a8fc-9784f3d54f3c"
23setup = """## Setup
24
25This rule requires data coming in from Elastic Defend.
26
27### Elastic Defend Integration Setup
28Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
29
30#### Prerequisite Requirements:
31- Fleet is required for Elastic Defend.
32- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
33
34#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
35- Go to the Kibana home page and click "Add integrations".
36- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
37- Click "Add Elastic Defend".
38- Configure the integration name and optionally add a description.
39- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
40- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
41- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
42- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
43For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
44- Click "Save and Continue".
45- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
46For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
47"""
48severity = "medium"
49tags = [
50 "Domain: Endpoint",
51 "OS: Linux",
52 "Use Case: Threat Detection",
53 "Tactic: Privilege Escalation",
54 "Tactic: Persistence",
55 "Data Source: Elastic Defend"
56 ]
57timestamp_override = "event.ingested"
58type = "eql"
59query = '''
60process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
61 (process.user.id == "0" and process.real_user.id != "0") or
62 (process.group.id == "0" and process.real_group.id != "0")
63) and (
64 process.name in (
65 "aa-exec", "ab", "agetty", "alpine", "ar", "arj", "arp", "as", "ascii-xfr", "ash", "aspell",
66 "atobm", "awk", "base32", "base64", "basenc", "basez", "bash", "bc", "bridge", "busctl",
67 "busybox", "bzip2", "cabal", "capsh", "cat", "choom", "chown", "chroot", "clamscan", "cmp",
68 "column", "comm", "cp", "cpio", "cpulimit", "csh", "csplit", "csvtool", "cupsfilter", "curl",
69 "cut", "dash", "date", "dd", "debugfs", "dialog", "diff", "dig", "distcc", "dmsetup", "docker",
70 "dosbox", "ed", "efax", "elvish", "emacs", "env", "eqn", "espeak", "expand", "expect", "file",
71 "find", "fish", "flock", "fmt", "fold", "gawk", "gcore", "gdb", "genie", "genisoimage", "gimp",
72 "grep", "gtester", "gzip", "hd", "head", "hexdump", "highlight", "hping3", "iconv", "install",
73 "ionice", "ispell", "jjs", "join", "jq", "jrunscript", "julia", "ksh", "ksshell", "kubectl",
74 "ld.so", "less", "links", "logsave", "look", "lua", "make", "mawk", "minicom", "more",
75 "mosquitto", "msgattrib", "msgcat", "msgconv", "msgfilter", "msgmerge", "msguniq", "multitime",
76 "mv", "nasm", "nawk", "ncftp", "nft", "nice", "nl", "nm", "nmap", "node", "nohup", "ntpdate",
77 "od", "openssl", "openvpn", "pandoc", "paste", "perf", "perl", "pexec", "pg", "php", "pidstat",
78 "pr", "ptx", "python", "rc", "readelf", "restic", "rev", "rlwrap", "rsync", "rtorrent",
79 "run-parts", "rview", "rvim", "sash", "scanmem", "sed", "setarch", "setfacl", "setlock", "shuf",
80 "soelim", "softlimit", "sort", "sqlite3", "ss", "ssh-agent", "ssh-keygen", "ssh-keyscan",
81 "sshpass", "start-stop-daemon", "stdbuf", "strace", "strings", "sysctl", "systemctl", "tac",
82 "tail", "taskset", "tbl", "tclsh", "tee", "terraform", "tftp", "tic", "time", "timeout", "troff",
83 "ul", "unexpand", "uniq", "unshare", "unsquashfs", "unzip", "update-alternatives", "uudecode",
84 "uuencode", "vagrant", "varnishncsa", "view", "vigr", "vim", "vimdiff", "vipw", "w3m", "watch",
85 "wc", "wget", "whiptail", "xargs", "xdotool", "xmodmap", "xmore", "xxd", "xz", "yash", "zsh",
86 "zsoelim"
87 ) or
88 process.name == "ip" and (
89 (process.args == "-force" and process.args in ("-batch", "-b")) or (process.args == "exec")
90 )
91)
92'''
93
94[[rule.threat]]
95framework = "MITRE ATT&CK"
96
97[[rule.threat.technique]]
98id = "T1068"
99name = "Exploitation for Privilege Escalation"
100reference = "https://attack.mitre.org/techniques/T1068/"
101
102[[rule.threat.technique]]
103id = "T1548"
104name = "Abuse Elevation Control Mechanism"
105reference = "https://attack.mitre.org/techniques/T1548/"
106
107[[rule.threat.technique.subtechnique]]
108id = "T1548.001"
109name = "Setuid and Setgid"
110reference = "https://attack.mitre.org/techniques/T1548/001/"
111
112[rule.threat.tactic]
113id = "TA0004"
114name = "Privilege Escalation"
115reference = "https://attack.mitre.org/tactics/TA0004/"
116
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119
120[rule.threat.tactic]
121id = "TA0003"
122name = "Persistence"
123reference = "https://attack.mitre.org/tactics/TA0003/"
References
Related rules
- Process Capability Set via setcap Utility
- Potential Sudo Hijacking
- At Job Created or Modified
- Kernel Load or Unload via Kexec Detected
- Potential Suspicious File Edit