T1059.013

Container CLI/API

Adversaries may abuse built-in CLI tools or API calls to execute malicious commands in containerized environments. The Docker CLI manages containers via the dockerd daemon API. Kubernetes kubectl and the Kubernetes API server enable cluster management. Adversaries may leverage Docker CLI/API/SDK to pull images, run containers, execute commands inside containers, and scan for cloud credentials. TeamTNT has extensively targeted misconfigured Docker and Kubernetes environments, using container CLIs to deploy cryptominers, exfiltrate cloud credentials, and spread laterally across clusters.

Microsoft Sentinel / Defender
kusto
let SuspiciousCommands = dynamic([
  "docker exec", "docker run",
  "docker pull", "docker build",
  "docker cp", "docker inspect",
  "docker ps", "docker images",
  "--privileged", "--cap-add=SYS_ADMIN",
  "--net=host", "--pid=host",
  "-v /:/host", "-v /etc:/", "-v /var/run/docker.sock",
  "kubectl exec", "kubectl run",
  "kubectl apply", "kubectl create",
  "kubectl get secrets", "kubectl get configmaps",
  "kubectl port-forward", "kubectl proxy",
  "crictl exec", "ctr run"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("docker", "kubectl", "crictl", "ctr", "podman", "nerdctl")
| where ProcessCommandLine has_any (SuspiciousCommands)
| extend PrivilegedContainer = ProcessCommandLine has_any ("--privileged", "--cap-add=SYS_ADMIN", "--net=host", "--pid=host")
| extend HostMount = ProcessCommandLine has_any ("-v /:/host", "-v /etc:/", "-v /var/run/docker.sock")
| extend ContainerExec = ProcessCommandLine has_any ("docker exec", "kubectl exec", "crictl exec")
| extend SecretsAccess = ProcessCommandLine has_any ("get secrets", "get configmaps")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         PrivilegedContainer, HostMount, ContainerExec, SecretsAccess
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: Process Creation Command: Command Execution Container: Container Creation

Required Tables

DeviceProcessEvents

False Positives

  • DevOps engineers and SREs using kubectl and docker for routine container management
  • CI/CD pipelines building and deploying container images
  • Container orchestration systems performing scheduled container operations

Unlock Pro Content

Get the full detection package for T1059.013 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections