Kubernetes User Exec into Pod
editKubernetes User Exec into Pod
editThis rule detects a user attempt to establish a shell session into a pod using the exec command. Using the exec command in a pod allows a user to establish a temporary shell session and execute any process/commands in the pod. An adversary may call bash to gain a persistent interactive shell which will allow access to any data the pod has permissions to, including secrets.
Rule type: query
Rule indices:
- logs-kubernetes.*
Severity: medium
Risk score: 47
Runs every: 5 minutes
Searches indices from: now-6m (Date Math format, see also Additional look-back time
)
Maximum alerts per execution: 100
References:
Tags:
- Elastic
- Kubernetes
- Continuous Monitoring
- Execution
Version: 200 (version history)
Added (Elastic Stack release): 8.3.0
Last modified (Elastic Stack release): 8.6.0
Rule authors: Elastic
Rule license: Elastic License v2
Potential false positives
editAn administrator may need to exec into a pod for a legitimate reason like debugging purposes. Containers built from Linux and Windows OS images, tend to include debugging utilities. In this case, an admin may choose to run commands inside a specific container with kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} — ${CMD} ${ARG1} ${ARG2} … ${ARGN}. For example, the following command can be used to look at logs from a running Cassandra pod: kubectl exec cassandra --cat /var/log/cassandra/system.log . Additionally, the -i and -t arguments might be used to run a shell connected to the terminal: kubectl exec -i -t cassandra — sh
Investigation guide
editRule query
editevent.dataset : "kubernetes.audit_logs" and kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" and kubernetes.audit.verb:"create" and kubernetes.audit.objectRef.resource:"pods" and kubernetes.audit.objectRef.subresource:"exec"
Threat mapping
editFramework: MITRE ATT&CKTM
-
Tactic:
- Name: Execution
- ID: TA0002
- Reference URL: https://attack.mitre.org/tactics/TA0002/
-
Technique:
- Name: Container Administration Command
- ID: T1609
- Reference URL: https://attack.mitre.org/techniques/T1609/
Rule version history
edit- Version 200 (8.6.0 release)
-
-
Updated query, changed from:
kubernetes.audit.objectRef.resource:"pods" and kubernetes.audit.objectRef.subresource:"exec"
-
- Version 100 (8.5.0 release)
-
-
Updated query, changed from:
kubernetes.audit.objectRef.resource:"pods" and kubernetes.audit.objectRef.subresource:"exec"
-
- Version 3 (8.4.0 release)
-
-
Updated query, changed from:
event.dataset:"kubernetes.audit_logs" and kubernetes.audit.objectRef.resource:"pods" and kubernetes.audit.objectRef.subresource:"exec"
-