Suspicious Network Connection via Sudo Binary

Detects network connections initiated by the "sudo" binary. This behavior is uncommon and may occur in instances where reverse shell shellcode is injected into a process run with elevated permissions via "sudo". Attackers may attempt to inject shellcode into processes running as root, to escalate privileges.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2024/01/15"
 3integration = ["endpoint"]
 4maturity = "production"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2024/03/08"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12Detects network connections initiated by the "sudo" binary. This behavior is uncommon and may occur in instances where
13reverse shell shellcode is injected into a process run with elevated permissions via "sudo". Attackers may attempt to
14inject shellcode into processes running as root, to escalate privileges. 
15"""
16from = "now-9m"
17index = ["logs-endpoint.events.*", "endgame-*"]
18language = "eql"
19license = "Elastic License v2"
20name = "Suspicious Network Connection via Sudo Binary"
21risk_score = 47
22rule_id = "30e1e9f2-eb9c-439f-aff6-1e3068e99384"
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        "Data Source: Elastic Defend",
56        "Data Source: Elastic Endgame"
57        ]
58timestamp_override = "event.ingested"
59type = "eql"
60query = '''
61network where host.os.type == "linux" and event.type == "start" and
62event.action in ("connection_attempted", "ipv4_connection_attempt_event") and process.name == "sudo"
63'''
64
65[[rule.threat]]
66framework = "MITRE ATT&CK"
67
68[[rule.threat.technique]]
69id = "T1055"
70name = "Process Injection"
71reference = "https://attack.mitre.org/techniques/T1055/"
72
73[[rule.threat.technique.subtechnique]]
74id = "T1055.008"
75name = "Ptrace System Calls"
76reference = "https://attack.mitre.org/techniques/T1055/008/"
77
78[[rule.threat.technique]]
79id = "T1548"
80name = "Abuse Elevation Control Mechanism"
81reference = "https://attack.mitre.org/techniques/T1548/"
82
83[[rule.threat.technique.subtechnique]]
84id = "T1548.003"
85name = "Sudo and Sudo Caching"
86reference = "https://attack.mitre.org/techniques/T1548/003/"
87
88[rule.threat.tactic]
89id = "TA0004"
90name = "Privilege Escalation"
91reference = "https://attack.mitre.org/tactics/TA0004/"

Related rules

to-top