Privilege Escalation via CAP_SETUID/SETGID Capabilities

Identifies instances where a process (granted CAP_SETUID and/or CAP_SETGID capabilities) is executed, after which the user's access is elevated to UID/GID 0 (root). In Linux, the CAP_SETUID and CAP_SETGID capabilities allow a process to change its UID and GID, respectively, providing control over user and group identity management. Attackers may leverage a misconfiguration for exploitation in order to escalate their privileges to root.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/01/08"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/11/07"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies instances where a process (granted CAP_SETUID and/or CAP_SETGID capabilities) is executed, after which the
 11user's access is elevated to UID/GID 0 (root). In Linux, the CAP_SETUID and CAP_SETGID capabilities allow a process to
 12change its UID and GID, respectively, providing control over user and group identity management. Attackers may leverage
 13a misconfiguration for exploitation in order to escalate their privileges to root.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Privilege Escalation via CAP_SETUID/SETGID Capabilities"
 20risk_score = 47
 21rule_id = "9b80cb26-9966-44b5-abbf-764fbdbc3586"
 22setup = """## Setup
 23
 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    "Data Source: Elastic Defend",
 55]
 56type = "eql"
 57
 58query = '''
 59sequence by host.id, process.entity_id with maxspan=1s
 60  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name != null and
 61   (process.thread.capabilities.effective : "CAP_SET?ID" or process.thread.capabilities.permitted : "CAP_SET?ID") and 
 62   user.id != "0" and not (
 63     process.parent.executable : ("/tmp/newroot/*", "/opt/carbonblack*") or
 64     process.parent.executable in (
 65       "/opt/SolarWinds/Agent/bin/Plugins/JobEngine/SolarWinds.Agent.JobEngine.Plugin", "/usr/bin/vmware-toolbox-cmd",
 66       "/usr/bin/dbus-daemon", "/usr/bin/update-notifier", "/usr/share/language-tools/language-options",
 67       "/opt/SolarWinds/Agent/*", "/usr/local/sbin/lynis.sh"
 68     ) or
 69     process.executable : ("/opt/dynatrace/*", "/tmp/newroot/*", "/opt/SolarWinds/Agent/*") or
 70     process.executable in (
 71       "/bin/fgrep", "/usr/bin/sudo", "/usr/bin/pkexec", "/usr/lib/cockpit/cockpit-session", "/usr/sbin/suexec"
 72     ) or
 73     process.parent.name in ("update-notifier", "language-options", "osqueryd", "saposcol", "dbus-daemon", "osqueryi", "sdbrun") or
 74     process.command_line like ("sudo*BECOME-SUCCESS*", "/bin/sh*sapsysinfo.sh*", "sudo su", "sudo su -") or
 75     process.name == "sudo" or
 76     process.parent.command_line like "/usr/bin/python*ansible*"
 77   )]
 78  [process where host.os.type == "linux" and event.action == "uid_change" and event.type == "change" and 
 79   (process.thread.capabilities.effective : "CAP_SET?ID" or process.thread.capabilities.permitted : "CAP_SET?ID")
 80   and user.id == "0"]
 81'''
 82
 83
 84[[rule.threat]]
 85framework = "MITRE ATT&CK"
 86[[rule.threat.technique]]
 87id = "T1068"
 88name = "Exploitation for Privilege Escalation"
 89reference = "https://attack.mitre.org/techniques/T1068/"
 90
 91[[rule.threat.technique]]
 92id = "T1548"
 93name = "Abuse Elevation Control Mechanism"
 94reference = "https://attack.mitre.org/techniques/T1548/"
 95[[rule.threat.technique.subtechnique]]
 96id = "T1548.001"
 97name = "Setuid and Setgid"
 98reference = "https://attack.mitre.org/techniques/T1548/001/"
 99
100
101
102[rule.threat.tactic]
103id = "TA0004"
104name = "Privilege Escalation"
105reference = "https://attack.mitre.org/tactics/TA0004/"

Related rules

to-top