|
| 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