Skip to main content

Runner

Medium Linux machine exploiting CVE‑2023‑42793 in TeamCity for initial access, followed by CVE‑2024‑21626 via Portainer for container escape and PrivEsc.

Nmap​

First 1000 TCP Ports​

Nmap Scan

Enumerating Web Server on port 80​

Ffuf for subdomains​

After running some fuzzing for any directories, nothing was found. Next we tried to look for subdomains, had to use the correct wordlist though.

Subdomain Fuzz

teamcity subdomain​

After adding the subdomain to the /etc/hosts file, we visited the webpage. Turns out it's hosting TeamCity, an advanced CI/CD platform.

TeamCity UI

Searching for version 2023.05.3 (build 129390) gave some interesting results on Exploit-DB.

Version Detection

Using this exploit, we created an admin account and logged in:

Exploit Success

We discovered some usernames in the admin dashboard:

Usernames

Usernames discovered:

UsernameName
adminJohn
matthewMatthew

Also found a backup functionality that allows downloading a zipped archive:

Backup Page

Options available for backup scope:

Backup Scope

We selected the “Basic” scope (which includes DB), downloaded and extracted the zip:

Backup Extracted

Found John’s password hash but couldn’t crack it. Matthew’s hash was crackable, but didn’t work over SSH.

Later, we found an SSH private key:

SSH Key

We tried it...

User Flag​

User Shell

We could connect as john using his SSH private key.

LinPEAS​

Running linpeas showed many open ports:

LinPEAS Ports

We got a response from port 9000:

Port 9000

We forwarded it locally via SSH:

ssh -i id_rsa john@10.10.11.13 -L 80:127.0.0.1:9000

Root Flag​

We landed on a Portainer instance — container management software.

Portainer Login

Using matthew’s cracked password, we logged in.

We created a volume mapping / from the host system using the Portainer GUI:

Volume Config

Add Volume

Driver Options

Then created a container using the teamcity:latest image:

Container Create

TeamCity Image Hash

Image Selected

Enabled interactive + TTY:

TTY Enabled

Mounted volume to a container path:

Volume Mount

Deployed container, got a shell — and the Root Flag:

Container Shell

Root Flag 1

Root Flag 2

Root Flag 3

Possible Other Exploitation Routes​

Another CVE also worked for the TeamCity version and landed us in a Docker container:

Alt Exploit Path