Detect Container Administration Command in Splunk
This detection identifies adversaries abusing container administration services such as the Docker daemon, Kubernetes API server, or kubelet to execute commands within running containers. Attackers leverage tools like 'docker exec', 'kubectl exec', or direct kubelet API calls to achieve code execution in containerized environments, often for lateral movement, cryptomining deployment, or establishing persistence. This detection monitors process creation events on container host nodes for suspicious invocations of container management binaries with exec sub-commands, privileged flags, or interactive shell spawning, as well as anomalous kubelet API activity patterns associated with threat actors like TeamTNT and malware families including Kinsing, Hildegard, and Siloscape.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1609 Container Administration Command
- Canonical reference
- https://attack.mitre.org/techniques/T1609/
SPL Detection Query
index=* (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1) OR (sourcetype="linux_secure" OR sourcetype="syslog")
| eval cmd=coalesce(CommandLine, process, command)
| eval proc=coalesce(Image, process_name, comm)
| search (proc="*docker*" OR proc="*kubectl*" OR proc="*crictl*" OR proc="*podman*" OR proc="*nerdctl*" OR proc="*ctr*")
AND (cmd="*exec*" OR cmd="*run*" OR cmd="*attach*")
| eval is_interactive_shell=if(match(cmd, "(-it|--tty|-i\s)"), 1, 0)
| eval spawns_shell=if(match(cmd, "(/bin/sh|/bin/bash|\bsh\b|\bbash\b|\bash\b|/bin/ash)"), 1, 0)
| eval privileged_flag=if(match(cmd, "(--privileged|--cap-add|--pid=host|--net=host|--ipc=host)"), 1, 0)
| eval is_kubectl_exec=if(match(proc, "kubectl") AND match(cmd, "exec"), 1, 0)
| eval parent=coalesce(ParentImage, parent_process, ppid)
| eval scripting_parent=if(match(parent, "(python|ruby|perl|php|node|nodejs)"), 1, 0)
| eval risk_score=(is_interactive_shell*30) + (spawns_shell*25) + (privileged_flag*35) + (is_kubectl_exec*20) + (scripting_parent*30)
| where risk_score >= 25
| eval host=coalesce(host, Computer, hostname)
| eval user=coalesce(User, user, src_user)
| table _time, host, user, proc, cmd, parent, is_interactive_shell, spawns_shell, privileged_flag, is_kubectl_exec, scripting_parent, risk_score
| sort - risk_score, _time Detects container administration command execution on both Windows container hosts (via Sysmon) and Linux container nodes (via syslog/linux_secure). Scores process creation events involving docker, kubectl, crictl, and podman with exec sub-commands against risk indicators including interactive shell spawning, privileged container flags, and scripting language parent processes indicating programmatic invocation.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Authorized platform engineering teams using kubectl exec for live container debugging, log inspection, or configuration validation in development and staging clusters
- Automated deployment orchestration tools running docker exec to perform post-start container initialization scripts or configuration injection
- Container security scanning tools (Falco, Aqua, Sysdig) that use crictl exec or docker exec to perform runtime compliance checks and policy validation
Other platforms for T1609
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Docker Exec Interactive Shell in Running Container
Expected signal: Sysmon EventCode=1 or Linux process creation event showing docker process with CommandLine containing 'exec -it atomic-test-container /bin/sh'. DeviceProcessEvents will show FileName=docker, ProcessCommandLine containing 'exec' and '/bin/sh'.
- Test 2Kubectl Exec Command Execution in Pod
Expected signal: DeviceProcessEvents showing FileName=kubectl, ProcessCommandLine containing 'exec atomic-exec-test -- /bin/sh'. Kubernetes API server audit log entry with verb=create, objectRef.subresource=exec, objectRef.name=atomic-exec-test. Linux audit log execve records for kubectl.
- Test 3Direct Kubelet API Exec Bypassing API Server
Expected signal: DeviceProcessEvents showing FileName=curl, ProcessCommandLine containing ':10250' and '/exec/' or '/pods'. Linux process creation audit records for curl with kubelet API endpoint arguments. Network connection to port 10250 in DeviceNetworkEvents.
References (8)
- https://attack.mitre.org/techniques/T1609/
- https://unit42.paloaltonetworks.com/hildegard-malware-teamtnt/
- https://aquasecurity.github.io/kube-hunter/
- https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec
- https://docs.docker.com/engine/reference/commandline/exec/
- https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/
- https://microsoft.com/security/blog/2023/07/25/threat-matrix-for-kubernetes/
- https://www.aquasec.com/blog/kinsing-malware-container-vulnerability/
Unlock Pro Content
Get the full detection package for T1609 including response playbook, investigation guide, and atomic red team tests.