[New Rule] Potential Container Escape via Modified release_agent File (#3242)

* [New Rule] Potential Container Escape via Modified release_agent File

This rule detects modification of the CGroup release_agent file from inside a privileged container. The release_agent is a script that is executed at the termination of any process on that CGroup and is invoked from the host. A privileged container with SYS_ADMIN capabilities, enables a threat actor to mount a CGroup directory and modify the release_agent which could be used for further privilege escalation and container escapes to the host machine.

* Apply 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>
This commit is contained in:
Isai
2024-01-04 21:24:54 -05:00
committed by GitHub
parent d7b62395e7
commit 0a37df713b
@@ -0,0 +1,59 @@
[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/14"
[rule]
author = ["Elastic"]
description = """
This rule detects modification of the CGroup release_agent file from inside a privileged container. The release_agent is
a script that is executed at the termination of any process on that CGroup and is invoked from the host. A privileged
container with SYS_ADMIN capabilities, enables a threat actor to mount a CGroup directory and modify the release_agent
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 release_agent File"
references = [
"https://blog.aquasec.com/threat-alert-container-escape",
"https://sysdig.com/blog/detecting-mitigating-cve-2022-0492-sysdig/",
"https://book.hacktricks.xyz/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation#privileged-escape-abusing-existent-release_agent-cve-2022-0492-poc1",
]
risk_score = 47
rule_id = "160896de-b66f-42cb-8fef-20f53a9006ea"
severity = "medium"
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 : "release_agent"
'''
[[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/"