Potential Privilege Escalation via Container Misconfiguration

This rule monitors for the execution of processes that interact with Linux containers through an interactive shell without root permissions. Utilities such as runc and ctr are universal command-line utilities leveraged to interact with containers via root permissions. On systems where the access to these utilities are misconfigured, attackers might be able to create and run a container that mounts the root folder or spawn a privileged container vulnerable to a container escape attack, which might allow them to escalate privileges and gain further access onto the host file system.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2023/07/31"
 3integration = ["endpoint"]
 4maturity = "production"
 5updated_date = "2024/05/21"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10This rule monitors for the execution of processes that interact with Linux containers through an interactive shell
11without root permissions. Utilities such as runc and ctr are universal command-line utilities leveraged to interact with
12containers via root permissions. On systems where the access to these utilities are misconfigured, attackers might be
13able to create and run a container that mounts the root folder or spawn a privileged container vulnerable to a container
14escape attack, which might allow them to escalate privileges and gain further access onto the host file system.
15"""
16from = "now-9m"
17index = ["logs-endpoint.events.*"]
18language = "eql"
19license = "Elastic License v2"
20name = "Potential Privilege Escalation via Container Misconfiguration"
21references = [
22    "https://book.hacktricks.xyz/linux-hardening/privilege-escalation/runc-privilege-escalation",
23    "https://book.hacktricks.xyz/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation",
24]
25risk_score = 47
26rule_id = "afe6b0eb-dd9d-4922-b08a-1910124d524d"
27setup = """## Setup
28
29This rule requires data coming in from Elastic Defend.
30
31### Elastic Defend Integration Setup
32Elastic 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.
33
34#### Prerequisite Requirements:
35- Fleet is required for Elastic Defend.
36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
37
38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
39- Go to the Kibana home page and click "Add integrations".
40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
41- Click "Add Elastic Defend".
42- Configure the integration name and optionally add a description.
43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
44- 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).
45- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
46- 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.
47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
48- Click "Save and Continue".
49- 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.
50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
51
52Session View uses process data collected by the Elastic Defend integration, but this data is not always collected by default. Session View is available on enterprise subscription for versions 8.3 and above.
53#### To confirm that Session View data is enabled:
54- Go to “Manage → Policies”, and edit one or more of your Elastic Defend integration policies.
55- Select the” Policy settings” tab, then scroll down to the “Linux event collection” section near the bottom.
56- Check the box for “Process events”, and turn on the “Include session data” toggle.
57- If you want to include file and network alerts in Session View, check the boxes for “Network and File events”.
58- If you want to enable terminal output capture, turn on the “Capture terminal output” toggle.
59For more information about the additional fields collected when this setting is enabled and the usage of Session View for Analysis refer to the [helper guide](https://www.elastic.co/guide/en/security/current/session-view.html).
60"""
61severity = "medium"
62tags = [
63    "Domain: Endpoint",
64    "OS: Linux",
65    "Use Case: Threat Detection",
66    "Tactic: Privilege Escalation",
67    "Domain: Container",
68    "Data Source: Elastic Defend",
69]
70timestamp_override = "event.ingested"
71type = "eql"
72
73query = '''
74process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
75  (process.name == "runc" and process.args == "run") or
76  (process.name == "ctr" and process.args == "run" and process.args in ("--privileged", "--mount"))
77) and not user.Ext.real.id == "0" and not group.Ext.real.id == "0" and 
78process.interactive == true and process.parent.interactive == true
79'''
80
81
82[[rule.threat]]
83framework = "MITRE ATT&CK"
84[[rule.threat.technique]]
85id = "T1611"
86name = "Escape to Host"
87reference = "https://attack.mitre.org/techniques/T1611/"
88
89
90[rule.threat.tactic]
91id = "TA0004"
92name = "Privilege Escalation"
93reference = "https://attack.mitre.org/tactics/TA0004/"

References

Related rules

to-top