Skip to content

[New Rule] PE via Container Misconfiguration #2983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 4, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[metadata]
creation_date = "2023/07/31"
integration = ["endpoint"]
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2023/07/31"

[rule]
author = ["Elastic"]
description = """
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.
"""
from = "now-9m"
index = ["logs-endpoint.events.*"]
language = "eql"
license = "Elastic License v2"
name = "Potential Privilege Escalation via Container Misconfiguration"
note = """## Setup
This rule leverages `session` fields, which requires that the collection of session data is enabled for Linux operating systems.

The following steps should be performed in order to enable session data event collection on a Linux system.
```
Kibana -->
Management -->
Fleet -->
Agent Policies -->
Agent Policy with Elastic Defend installed -->
Elastic Defend integration -->
Enable the "Collect session data" box under "Event Collection" for "Linux"
```
More information on this topic and how to enable session data collection can be found at https://www.elastic.co/blog/secure-your-cloud-with-cloud-workload-protection-in-elastic-security.
"""
references = [
"https://book.hacktricks.xyz/linux-hardening/privilege-escalation/runc-privilege-escalation",
"https://book.hacktricks.xyz/linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation"
]
risk_score = 47
rule_id = "afe6b0eb-dd9d-4922-b08a-1910124d524d"
severity = "medium"
tags = ["Domain: Endpoint", "OS: Linux", "Use Case: Threat Detection", "Tactic: Privilege Escalation", "Domain: Container"]
timestamp_override = "event.ingested"
type = "eql"
query = '''
process where host.os.type == "linux" and event.action == "exec" and event.type == "start" and (
(process.name == "runc" and process.args == "run") or
(process.name == "ctr" and process.args == "run" and process.args in ("--privileged", "--mount"))
) and not user.Ext.real.id == "0" and not group.Ext.real.id == "0" and
process.interactive == true and process.parent.interactive == true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these fields dependent on session data? If so, we may want to add it in setup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, totally forgot about that. Added a small setup guide to the rule!

'''

[[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/"