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