Zabbix Agent RCE
Zabbix agents can execute arbitrary system commands when EnableRemoteCommands=1 or AllowKey=system.run[*] is configured. This leads to RCE either through direct agent communication (port 10050) or through the web interface by creating an item or action that calls system.run. Confirm access through Zabbix enumeration first.
Direct Agent Command Execution
If the Zabbix agent (port 10050) accepts connections from your IP and system.run is enabled, execute commands directly.
ZBXDuid=0(root) gid=0(root) groups=0(root)
If system.run is disabled, the response will be "ZBX_NOTSUPPORTED" instead. The agent often runs as root, giving immediate root-level command execution.
Start nc -lvnp on your listener port first. The agent executes the command and returns the output (or hangs if the shell connects back).
RCE via Web Interface (Admin Access)
With admin credentials to the Zabbix web frontend, create a monitored item that executes system.run on a target host's agent.
Steps through the web UI:
- Navigate to Configuration > Hosts and select the target host.
- Go to Items and click Create item.
- Set Name to anything, Type to "Zabbix agent", Key to
system.run[id]. - Set Update interval to 30s and click Add.
- Check Monitoring > Latest data for the command output.
Alternatively, use the API to create the item programmatically:
Replace hostid with the target host ID from host.get. type=0 is Zabbix agent, value_type=1 is text. The item executes every 30 seconds on the agent.
RCE via Global Scripts
Zabbix global scripts are pre-configured commands that admins can execute on any monitored host. With admin access, create a new script or modify an existing one.
type=0 is script, execute_on=1 is Zabbix agent, scope=2 is manual host action. After creation, execute it from Monitoring > Hosts by clicking the host name and selecting the script.
Replace <SCRIPT_ID> with the ID from script.create response. Start your listener before executing.
Reading Files via Agent
Even if system.run is disabled, the vfs.file.contents key reads files from the agent host.
vfs.file.contents is a built-in key that is allowed by default. Read sensitive files like /etc/shadow (if agent runs as root), SSH keys, and application configs.
References
-
Zabbix: Agent Item KeysDOCS: Zabbix: Agent Item Keys, www.zabbix.com/documentation/current/en/manual/config/items/itemtypes/zabbix_agent (opens in new tab)
Official documentation on agent item keys including system.run and vfs.file.contents.
-
HackTricks: Pentesting ZabbixTOOL: HackTricks: Pentesting Zabbix, hacktricks.wiki/en/network-services-pentesting/pentesting-web/zabbix.html (opens in new tab)
Zabbix exploitation techniques including agent RCE and API abuse.