From 8e1dad0aebe7e1f13d61713f7fbdc00ebfde1719 Mon Sep 17 00:00:00 2001 From: Isai <59296946+imays11@users.noreply.github.com> Date: Thu, 4 Jan 2024 22:14:39 -0500 Subject: [PATCH] [New Rule] Potential Container Escape via Modified notify_on_release File (#3244) * [New Rule] Potential Container Escape via Modified notify_on_release File This rule detects modification of the cgroup notify_on_release file from inside a container. When the notify_on_release flag is enabled (1) in a cgroup, then whenever the last task in the cgroup exits or attaches to another cgroup, the command specified in the release_agent file is run and invoked from the host. A privileged container with SYS_ADMIN capabilities, enables a threat actor to mount a cgroup directory and modify the notify_on_release flag in order to take advantage of this feature, which could be used for further privilege escalation and container escapes to the host machine. * Apply suggestions from code review * suggestions from code review Co-authored-by: Ruben Groenewoud <78494512+Aegrah@users.noreply.github.com> --------- Co-authored-by: Colson Wilhoit <48036388+DefSecSentinel@users.noreply.github.com> Co-authored-by: Ruben Groenewoud <78494512+Aegrah@users.noreply.github.com> --- ...e_via_modified_notify_on_release_file.toml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 rules/integrations/cloud_defend/privilege_escalation_potential_container_escape_via_modified_notify_on_release_file.toml diff --git a/rules/integrations/cloud_defend/privilege_escalation_potential_container_escape_via_modified_notify_on_release_file.toml b/rules/integrations/cloud_defend/privilege_escalation_potential_container_escape_via_modified_notify_on_release_file.toml new file mode 100644 index 000000000..7d3c3b6c2 --- /dev/null +++ b/rules/integrations/cloud_defend/privilege_escalation_potential_container_escape_via_modified_notify_on_release_file.toml @@ -0,0 +1,60 @@ +[metadata] +creation_date = "2023/10/26" +integration = ["cloud_defend"] +maturity = "production" +min_stack_comments = "New Integration: Cloud Defend" +min_stack_version = "8.8.0" +updated_date = "2023/12/18" + +[rule] +author = ["Elastic"] +description = """ +This rule detects modification of the cgroup notify_on_release file from inside a container. When the notify_on_release +flag is enabled (1) in a cgroup, then whenever the last task in the cgroup exits or attaches to another cgroup, the +command specified in the release_agent file is run and invoked from the host. A privileged container with SYS_ADMIN +capabilities, enables a threat actor to mount a cgroup directory and modify the notify_on_release flag in order to take +advantage of this feature, which could be used for further privilege escalation and container escapes to the host +machine. +""" +from = "now-6m" +index = ["logs-cloud_defend*"] +interval = "5m" +language = "eql" +license = "Elastic License v2" +name = "Potential Container Escape via Modified notify_on_release File" +references = [ + "https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/", + "https://sysdig.com/blog/detecting-mitigating-cve-2022-0492-sysdig/", +] +risk_score = 73 +rule_id = "ef65e82c-d8b4-4895-9824-5f6bc6166804" +severity = "high" +tags = [ + "Data Source: Elastic Defend for Containers", + "Domain: Container", + "OS: Linux", + "Use Case: Threat Detection", + "Tactic: Privilege Escalation", +] +timestamp_override = "event.ingested" +type = "eql" + +query = ''' +file where event.module == "cloud_defend" and event.action == "open" and +event.type == "change" and file.name : "notify_on_release" +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1611" +name = "Escape to Host" +reference = "https://attack.mitre.org/techniques/T1611/" + + +[rule.threat.tactic] +id = "TA0004" +name = "Privilege Escalation" +reference = "https://attack.mitre.org/tactics/TA0004/" +