Skip to content

Commit 4d3016f

Browse files
committed
[New Rule] Kubeconfig File Discovery
1 parent 5273729 commit 4d3016f

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
[metadata]
2+
creation_date = "2025/06/17"
3+
integration = ["endpoint"]
4+
maturity = "production"
5+
updated_date = "2025/06/17"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
The kubeconfig file is a critical component in Kubernetes environments, containing configuration
11+
details for accessing and managing Kubernetes clusters. Attackers may attempt to get access to,
12+
create or modify kubeconfig files to gain unauthorized initial access to Kubernetes clusters or
13+
move laterally within the cluster. This rule detects process discovery executions that involve
14+
kubeconfig files, particularly those executed from common shell environments or world-writeable
15+
directories.
16+
"""
17+
from = "now-9m"
18+
index = [
19+
"logs-endpoint.events.process*",
20+
]
21+
language = "eql"
22+
license = "Elastic License v2"
23+
name = "Kubeconfig File Discovery"
24+
references = [
25+
"https://kubernetes-threat-matrix.redguard.ch/initial-access/kubeconfig-file/",
26+
"https://kubenomicon.com/Initial_access/Kubeconfig_file.html",
27+
]
28+
risk_score = 21
29+
rule_id = "9a6f5d74-c7e7-4a8b-945e-462c102daee4"
30+
setup = """## Setup
31+
32+
This rule requires data coming in from Elastic Defend.
33+
34+
### Elastic Defend Integration Setup
35+
Elastic 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.
36+
37+
#### Prerequisite Requirements:
38+
- Fleet is required for Elastic Defend.
39+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
40+
41+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
42+
- Go to the Kibana home page and click "Add integrations".
43+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
44+
- Click "Add Elastic Defend".
45+
- Configure the integration name and optionally add a description.
46+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
47+
- 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).
48+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
49+
- 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.
50+
For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
51+
- Click "Save and Continue".
52+
- 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.
53+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
54+
"""
55+
severity = "low"
56+
tags = [
57+
"Domain: Endpoint",
58+
"Domain: Container",
59+
"OS: Linux",
60+
"Use Case: Threat Detection",
61+
"Tactic: Discovery",
62+
"Data Source: Elastic Defend",
63+
]
64+
timestamp_override = "event.ingested"
65+
type = "eql"
66+
query = '''
67+
process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
68+
process.parent.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") or
69+
(
70+
process.parent.executable like ("/tmp/*", "/var/tmp/*", "/dev/shm/*", "/root/*", "/home/*") or
71+
process.parent.name like (".*", "*.sh")
72+
)
73+
) and
74+
(
75+
(
76+
process.working_directory like ("/etc/kubernetes", "/root/.kube", "/home/*/.kube") and
77+
process.args in ("kubeconfig", "admin.conf", "super-admin.conf", "kubelet.conf", "controller-manager.conf", "scheduler.conf")
78+
) or
79+
process.args like (
80+
"/etc/kubernetes/admin.conf",
81+
"/etc/kubernetes/super-admin.conf",
82+
"/etc/kubernetes/kubelet.conf",
83+
"/etc/kubernetes/controller-manager.conf",
84+
"/etc/kubernetes/scheduler.conf",
85+
"/home/*/.kube/config",
86+
"/root/.kube/config",
87+
"/var/lib/*/kubeconfig"
88+
)
89+
) and not process.name in ("stat", "md5sum", "dirname")
90+
'''
91+
92+
[[rule.threat]]
93+
framework = "MITRE ATT&CK"
94+
95+
[[rule.threat.technique]]
96+
id = "T1613"
97+
name = "Container and Resource Discovery"
98+
reference = "https://attack.mitre.org/techniques/T1613/"
99+
100+
[rule.threat.tactic]
101+
id = "TA0007"
102+
name = "Discovery"
103+
reference = "https://attack.mitre.org/tactics/TA0007/"

0 commit comments

Comments
 (0)