Root Network Connection via GDB CAP_SYS_PTRACE

Identifies instances where GDB (granted the CAP_SYS_PTRACE capability) is executed, after which an outbound network connection is initiated by UID/GID 0 (root). In Linux, the CAP_SYS_PTRACE capability grants a process the ability to use the ptrace system call, which is typically used for debugging and allows the process to trace and control other processes. Attackers may leverage this capability to hook and inject into a process that is running with root permissions in order to execute shell code and gain a reverse shell with root privileges.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/01/09"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/11/07"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies instances where GDB (granted the CAP_SYS_PTRACE capability) is executed, after which an outbound network
 11connection is initiated by UID/GID 0 (root). In Linux, the CAP_SYS_PTRACE capability grants a process the ability to use
 12the ptrace system call, which is typically used for debugging and allows the process to trace and control other
 13processes. Attackers may leverage this capability to hook and inject into a process that is running with root
 14permissions in order to execute shell code and gain a reverse shell with root privileges.
 15"""
 16from = "now-9m"
 17index = ["logs-endpoint.events.*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "Root Network Connection via GDB CAP_SYS_PTRACE"
 21risk_score = 47
 22rule_id = "28bc620d-b2f7-4132-b372-f77953881d05"
 23setup = """## Setup
 24
 25
 26This rule requires data coming in from Elastic Defend.
 27
 28### Elastic Defend Integration Setup
 29Elastic 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.
 30
 31#### Prerequisite Requirements:
 32- Fleet is required for Elastic Defend.
 33- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 34
 35#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 36- Go to the Kibana home page and click "Add integrations".
 37- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 38- Click "Add Elastic Defend".
 39- Configure the integration name and optionally add a description.
 40- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 41- 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).
 42- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 43- 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.
 44For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 45- Click "Save and Continue".
 46- 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.
 47For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 48"""
 49severity = "medium"
 50tags = [
 51    "Domain: Endpoint",
 52    "OS: Linux",
 53    "Use Case: Threat Detection",
 54    "Tactic: Privilege Escalation",
 55    "Tactic: Execution",
 56    "Tactic: Command and Control",
 57    "Data Source: Elastic Defend",
 58]
 59type = "eql"
 60
 61query = '''
 62sequence by host.id, process.entry_leader.entity_id with maxspan=30s
 63  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name == "gdb" and
 64   (process.thread.capabilities.effective : "CAP_SYS_PTRACE" or process.thread.capabilities.permitted : "CAP_SYS_PTRACE") and
 65   user.id != "0"]
 66  [network where host.os.type == "linux" and event.action == "connection_attempted" and event.type == "start" and
 67   process.name != null and user.id == "0"]
 68'''
 69
 70
 71[[rule.threat]]
 72framework = "MITRE ATT&CK"
 73[[rule.threat.technique]]
 74id = "T1055"
 75name = "Process Injection"
 76reference = "https://attack.mitre.org/techniques/T1055/"
 77[[rule.threat.technique.subtechnique]]
 78id = "T1055.008"
 79name = "Ptrace System Calls"
 80reference = "https://attack.mitre.org/techniques/T1055/008/"
 81
 82
 83[[rule.threat.technique]]
 84id = "T1068"
 85name = "Exploitation for Privilege Escalation"
 86reference = "https://attack.mitre.org/techniques/T1068/"
 87
 88
 89[rule.threat.tactic]
 90id = "TA0004"
 91name = "Privilege Escalation"
 92reference = "https://attack.mitre.org/tactics/TA0004/"
 93[[rule.threat]]
 94framework = "MITRE ATT&CK"
 95[[rule.threat.technique]]
 96id = "T1059"
 97name = "Command and Scripting Interpreter"
 98reference = "https://attack.mitre.org/techniques/T1059/"
 99[[rule.threat.technique.subtechnique]]
100id = "T1059.004"
101name = "Unix Shell"
102reference = "https://attack.mitre.org/techniques/T1059/004/"
103
104
105
106[rule.threat.tactic]
107id = "TA0002"
108name = "Execution"
109reference = "https://attack.mitre.org/tactics/TA0002/"
110[[rule.threat]]
111framework = "MITRE ATT&CK"
112[[rule.threat.technique]]
113id = "T1071"
114name = "Application Layer Protocol"
115reference = "https://attack.mitre.org/techniques/T1071/"
116
117
118[rule.threat.tactic]
119id = "TA0011"
120name = "Command and Control"
121reference = "https://attack.mitre.org/tactics/TA0011/"

Related rules

to-top