Skip to content

Commit 0847c32

Browse files
authored
[New Rule] Potential Kubectl Masquerading (#4832)
* [New Rule] Potential Kubectl Masquerading * Update defense_evasion_potential_kubectl_masquerading.toml * ++ * ++ * Update defense_evasion_potential_kubectl_masquerading.toml * Update rules/linux/defense_evasion_potential_kubectl_masquerading.toml
1 parent d0bff94 commit 0847c32

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
[metadata]
2+
creation_date = "2025/06/19"
3+
integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
4+
maturity = "production"
5+
updated_date = "2025/06/19"
6+
7+
[rule]
8+
author = ["Elastic"]
9+
description = """
10+
This rule detects potential kubectl masquerading activity by monitoring for process events where the process name
11+
is not "kubectl" but the command line arguments include kubectl-related commands. This could indicate an adversary
12+
attempting to masquerade as legitimate kubectl activity to evade detection. This rule covers evasion gaps
13+
introduced by renaming the kubectl binary, or placing it in an unusual directory.
14+
"""
15+
from = "now-9m"
16+
index = [
17+
"endgame-*",
18+
"logs-crowdstrike.fdr*",
19+
"logs-endpoint.events.process*",
20+
"logs-sentinel_one_cloud_funnel.*",
21+
]
22+
language = "eql"
23+
license = "Elastic License v2"
24+
name = "Potential Kubectl Masquerading via Unexpected Process"
25+
references = ["https://kubernetes.io/docs/reference/kubectl/"]
26+
risk_score = 21
27+
rule_id = "2388c687-cb2c-4b7b-be8f-6864a2385048"
28+
setup = """## Setup
29+
30+
This rule requires data coming in from Elastic Defend.
31+
32+
### Elastic Defend Integration Setup
33+
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.
34+
35+
#### Prerequisite Requirements:
36+
- Fleet is required for Elastic Defend.
37+
- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
38+
39+
#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
40+
- Go to the Kibana home page and click "Add integrations".
41+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
42+
- Click "Add Elastic Defend".
43+
- Configure the integration name and optionally add a description.
44+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
45+
- 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).
46+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
47+
- 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.
48+
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).
49+
- Click "Save and Continue".
50+
- 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.
51+
For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
52+
"""
53+
severity = "low"
54+
tags = [
55+
"Domain: Endpoint",
56+
"Domain: Container",
57+
"Domain: Kubernetes",
58+
"OS: Linux",
59+
"Use Case: Threat Detection",
60+
"Tactic: Defense Evasion",
61+
"Data Source: Elastic Defend",
62+
"Data Source: Elastic Endgame",
63+
"Data Source: Crowdstrike",
64+
"Data Source: SentinelOne",
65+
]
66+
timestamp_override = "event.ingested"
67+
type = "eql"
68+
query = '''
69+
process where host.os.type == "linux" and event.type == "start" and
70+
event.action in ("exec", "exec_event", "start", "executed", "process_started") and
71+
(
72+
process.executable like~ ("/tmp/*", "/var/tmp/*", "/dev/shm/*", "/root/*", "/var/www/*", "./kubectl", "/home/*/kubectl") or
73+
process.name like ".*"
74+
) and
75+
process.command_line like~ (
76+
77+
// get and describe commands
78+
"*get po*", "*get deploy*", "*get node*", "*get svc*", "*get service*", "*get secret*", "*get clusterrole*", "*get ingress*",
79+
"*get configmap*", "*describe po*", "*describe deploy*", "*describe node*", "*describe svc*", "*describe service*",
80+
"*describe secret*", "*describe configmap*", "*describe clusterrole*", "*describe ingress*",
81+
82+
// exec commands
83+
"*exec -it*", "*exec --stdin*", "*exec --tty*",
84+
85+
// networking commands
86+
"*port-forward* ", "*proxy --port*", "*run --image=*", "*expose*",
87+
88+
// authentication/impersonation commands
89+
"*auth can-i*", "*--kubeconfig*", "*--as *", "*--as=*", "*--as-group*", "*--as-uid*"
90+
) and not (
91+
process.executable like "/tmp/newroot/*" or
92+
process.name == ".flatpak-wrapped"
93+
)
94+
'''
95+
96+
[[rule.threat]]
97+
framework = "MITRE ATT&CK"
98+
99+
[[rule.threat.technique]]
100+
id = "T1036"
101+
name = "Masquerading"
102+
reference = "https://attack.mitre.org/techniques/T1036/"
103+
104+
[[rule.threat.technique.subtechnique]]
105+
id = "T1036.003"
106+
name = "Rename Legitimate Utilities"
107+
reference = "https://attack.mitre.org/techniques/T1036/003/"
108+
109+
[[rule.threat.technique]]
110+
id = "T1564"
111+
name = "Hide Artifacts"
112+
reference = "https://attack.mitre.org/techniques/T1564/"
113+
114+
[rule.threat.tactic]
115+
id = "TA0005"
116+
name = "Defense Evasion"
117+
reference = "https://attack.mitre.org/tactics/TA0005/"

0 commit comments

Comments
 (0)