Skip to content

Commit 2272460

Browse files
imays11github-actions[bot]
authored andcommitted
[New Rule] Kubernetes execution_user_exec_to_pod (#1979)
* Create execution_user_exec_to_pod.toml * Update execution_user_exec_to_pod.toml * Update rules/integrations/kubernetes/execution_user_exec_to_pod.toml * Update non-ecs-schema.json * Update execution_user_exec_to_pod.toml * Update rules/integrations/kubernetes/execution_user_exec_to_pod.toml Co-authored-by: Terrance DeJesus <[email protected]> * Update execution_user_exec_to_pod.toml * Update execution_user_exec_to_pod.toml * Update execution_user_exec_to_pod.toml * toml-linted file and add to false positive toml-linted the file and added to the false positive description * Create notepad.sct Added this back into the repo, deleted by mistake. * added min_stack_version based on integration min stack version determined by integration support of necessary fields Co-authored-by: Jonhnathan <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]> Co-authored-by: Colson Wilhoit <[email protected]> (cherry picked from commit 63fda01)
1 parent 111b7c7 commit 2272460

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

detection_rules/etc/non-ecs-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,9 @@
5656
},
5757
"logs-windows.*": {
5858
"powershell.file.script_block_text": "text"
59+
},
60+
"logs-kubernetes.*": {
61+
"kubernetes.audit.objectRef.resource": "keyword",
62+
"kubernetes.audit.objectRef.subresource": "keyword"
5963
}
6064
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[metadata]
2+
creation_date = "2022/05/17"
3+
integration = "kubernetes"
4+
maturity = "production"
5+
min_stack_comments = "Necessary audit log fields not available prior to 8.2"
6+
min_stack_version = "8.2"
7+
updated_date = "2022/06/09"
8+
9+
[rule]
10+
author = ["Elastic"]
11+
description = """
12+
This rule detects a user attempt to establish a shell session into a pod using the 'exec' command. Using the 'exec'
13+
command in a pod allows a user to establish a temporary shell session and execute any process/commands in the pod. An
14+
adversary may call bash to gain a persistent interactive shell which will allow access to any data the pod has
15+
permissions to, including secrets.
16+
"""
17+
false_positives = [
18+
"""
19+
An administrator may need to exec into a pod for a legitimate reason like debugging purposes. Containers built from
20+
Linux and Windows OS images, tend to include debugging utilities. In this case, an admin may choose to run commands
21+
inside a specific container with kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} -- ${CMD} ${ARG1} ${ARG2} ...
22+
${ARGN}. For example, the following command can be used to look at logs from a running Cassandra pod: kubectl exec
23+
cassandra --cat /var/log/cassandra/system.log . Additionally, the -i and -t arguments might be used to run a shell
24+
connected to the terminal: kubectl exec -i -t cassandra -- sh
25+
""",
26+
]
27+
index = ["logs-kubernetes.*"]
28+
language = "kuery"
29+
license = "Elastic License v2"
30+
name = "Kubernetes User Exec into Pod"
31+
note = """## Config
32+
33+
The Kubernetes Fleet integration with Audit Logs enabled or similarly structured data is required to be compatible with this rule."""
34+
references = [
35+
"https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/",
36+
"https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/",
37+
]
38+
risk_score = 47
39+
rule_id = "14de811c-d60f-11ec-9fd7-f661ea17fbce"
40+
severity = "medium"
41+
tags = ["Elastic", "Kubernetes", "Continuous Monitoring", "Execution"]
42+
timestamp_override = "event.ingested"
43+
type = "query"
44+
45+
query = '''
46+
event.dataset:"kubernetes.audit_logs"
47+
and kubernetes.audit.objectRef.resource:"pods"
48+
and kubernetes.audit.objectRef.subresource:"exec"
49+
'''
50+
51+
52+
[[rule.threat]]
53+
framework = "MITRE ATT&CK"
54+
[[rule.threat.technique]]
55+
id = "T1609"
56+
name = "Container Administration Command"
57+
reference = "https://attack.mitre.org/techniques/T1609/"
58+
59+
60+
[rule.threat.tactic]
61+
id = "TA0002"
62+
name = "Execution"
63+
reference = "https://attack.mitre.org/tactics/TA0002/"
64+

0 commit comments

Comments
 (0)