概要
因为未能过滤掉latest.php页面中toggle_ids数组的输入,导致Zabbix 2.2.x,3.0.x 远程SQL注入
源码分析
下载了两份官方代码对比,左为3.0.4(已修复的版本),右为3.0.3
\zabbix-3.0.3rc1\frontends\php\jsrpc.php
可见新版本中删除的代码即为漏洞触发部分。
/*
* Ajax
*/
if (hasRequest('favobj')) {
if ($_REQUEST['favobj'] == 'toggle') {
// $_REQUEST['toggle_ids'] can be single id or list of ids,
// where id xxxx is application id and id 0_xxxx is 0_ + host id
if (!is_array($_REQUEST['toggle_ids'])) {
if ($_REQUEST['toggle_ids'][1] == '_') {
$hostId = substr($_REQUEST['toggle_ids'], 2);
CProfile::update('web.latest.toggle_other', $_REQUEST['toggle_open_state'], PROFILE_TYPE_INT, $hostId);
}
else {
$applicationId = $_REQUEST['toggle_ids'];
CProfile::update('web.latest.toggle', $_REQUEST['toggle_open_state'], PROFILE_TYPE_INT, $applicationId);
}
}
else {
foreach ($_REQUEST['toggle_ids'] as $toggleId) {
if ($toggleId[1] == '_') {
$hostId = substr($toggleId, 2);
CProfile::update('web.latest.toggle_other', $_REQUEST['toggle_open_state'], PROFILE_TYPE_INT, $hostId);
}
else {
$applicationId = $toggleId;
CProfile::update(