Kubeconfig File Creation or Modification
The kubeconfig file is a critical component in Kubernetes environments, containing configuration details for accessing and managing Kubernetes clusters. Attackers may attempt to get access to, create or modify kubeconfig files to gain unauthorized initial access to Kubernetes clusters or move laterally within the cluster.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/06/17"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/06/17"
6
7[rule]
8author = ["Elastic"]
9description = """
10The kubeconfig file is a critical component in Kubernetes environments, containing configuration
11details for accessing and managing Kubernetes clusters. Attackers may attempt to get access to,
12create or modify kubeconfig files to gain unauthorized initial access to Kubernetes clusters or
13move laterally within the cluster.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.file*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Kubeconfig File Creation or Modification"
20references = [
21 "https://kubernetes-threat-matrix.redguard.ch/initial-access/kubeconfig-file/",
22 "https://kubenomicon.com/Initial_access/Kubeconfig_file.html",
23 ]
24risk_score = 47
25rule_id = "b11116fd-023c-4718-aeb8-fa9d283fc53b"
26setup = """## Setup
27
28This rule requires data coming in from Elastic Defend.
29
30### Elastic Defend Integration Setup
31Elastic 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.
32
33#### Prerequisite Requirements:
34- Fleet is required for Elastic Defend.
35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
36
37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
38- Go to the Kibana home page and click "Add integrations".
39- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
40- Click "Add Elastic Defend".
41- Configure the integration name and optionally add a description.
42- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
43- 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).
44- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
45- 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.
46
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"""
52severity = "medium"
53tags = [
54 "Domain: Endpoint",
55 "Domain: Container",
56 "OS: Linux",
57 "Use Case: Threat Detection",
58 "Tactic: Lateral Movement",
59 "Tactic: Defense Evasion",
60 "Tactic: Initial Access",
61 "Data Source: Elastic Defend"
62]
63timestamp_override = "event.ingested"
64type = "eql"
65query = '''
66file where host.os.type == "linux" and event.type != "deletion" and file.path like (
67 "/root/.kube/config",
68 "/home/*/.kube/config",
69 "/etc/kubernetes/admin.conf",
70 "/etc/kubernetes/super-admin.conf",
71 "/etc/kubernetes/kubelet.conf",
72 "/etc/kubernetes/controller-manager.conf",
73 "/etc/kubernetes/scheduler.conf",
74 "/var/lib/*/kubeconfig"
75) and not (
76 process.name in ("kubeadm", "kubelet", "vcluster", "minikube") or
77 (process.name == "sed" and file.Ext.original.name like "sed*")
78)
79'''
80
81[[rule.threat]]
82framework = "MITRE ATT&CK"
83
84[[rule.threat.technique]]
85id = "T1550"
86name = "Use Alternate Authentication Material"
87reference = "https://attack.mitre.org/techniques/T1550/"
88
89[rule.threat.tactic]
90id = "TA0008"
91name = "Lateral Movement"
92reference = "https://attack.mitre.org/tactics/TA0008/"
93
94[[rule.threat]]
95framework = "MITRE ATT&CK"
96
97[[rule.threat.technique]]
98id = "T1550"
99name = "Use Alternate Authentication Material"
100reference = "https://attack.mitre.org/techniques/T1550/"
101
102[rule.threat.tactic]
103id = "TA0005"
104name = "Defense Evasion"
105reference = "https://attack.mitre.org/tactics/TA0005/"
106
107[[rule.threat]]
108framework = "MITRE ATT&CK"
109
110[rule.threat.tactic]
111id = "TA0001"
112name = "Initial Access"
113reference = "https://attack.mitre.org/tactics/TA0001/"
114
115[[rule.threat.technique]]
116id = "T1078"
117name = "Valid Accounts"
118reference = "https://attack.mitre.org/techniques/T1078/"
References
Related rules
- Kubeconfig File Discovery
- Kubectl Permission Discovery
- Potential CVE-2025-33053 Exploitation
- Loadable Kernel Module Configuration File Creation
- Unusual LD_PRELOAD/LD_LIBRARY_PATH Command Line Arguments