Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:27828
HistoryMar 20, 2012 - 12:00 a.m.

ManageEngine DeviceExpert 5.6 Java Server ScheduleResultViewer servlet Unauthenticated Remote Directory Traversal Vulnerability

2012-03-2000:00:00
vulners.com
31

ManageEngine DeviceExpert 5.6 Java Server ScheduleResultViewer servlet Unauthenticated
Remote Directory Traversal Vulnerability

product homepage: http://www.manageengine.com/products/device-expert/
file tested: ManageEngine_DeviceExpert.exe
tested against: Microsoft Windows Server 2003 r2 sp2

Description:
"DeviceExpert is a web–based, multi vendor network change, configuration and
compliance management (NCCCM) solution for switches, routers, firewalls and
other network devices. Trusted by thousands of network administrators
around the world, DeviceExpert helps automate and take total control
of the entire life cycle of device configuration management."
[…]

Background:
The mentioned product installs a Java application server
which listen by default on port 6060 (https) for incoming
connections.

Vulnerability:
Without prior authentication, is possible to invoke the
ScheduleResultViewer servlet to disclose every file
on target system. This can be done through the
FileName argument which suffers of a directory traversal
vulnerability.

examples:

https://[host]:6060/scheduleresult.de/?FileName=conf\Authentication\auth-conf.xml
https://[host]:6060/scheduleresult.de/?FileName=…\…\…\…\…\…\…\…\…\…\boot.ini

auth-conf.xml stores the authentication credentials to the
administrative interface (username, hashed password and a salt).
It is also possible to backup the MySQL database tables by cycling
through subfolders.
Theese tables can contain also usernames and passwords of
the configured devices, remember the software functionality,
it supports multiple vendors devices from the following list:

.
Cisco, HP, Nortel, Juniper, Force10, 3Com, D-link, Foundry, Dell, Aruba, Extreme, ADTRAN, Enterasys, Huawei, Blue Coat, Proxim, NetScreen, NETGEAR, FortiNet, ALAXALA, Brocade, Radware, DAX, H3C, Yamaha, Vanguard, Allied Telesis, Alcatel, Fujitsu, Motorola, Acme Packet, Watch Guard, Canoga Perkins
.

Explaination:

look at the web.xml located inside C:\ManageEngine\DeviceExpert\webapps\ncm\WEB-INF\ :

.
<servlet>
<servlet-name>ScheduleResultViewer</servlet-name>
<servlet-class>com.adventnet.ncm.client.schedule.ScheduleResultViewerServlet</servlet-class>
</servlet>

&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;ScheduleResultViewer&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/scheduleresult.de/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

.

now decompile ScheduleResultViewerServlet.class:

.
package com.adventnet.ncm.client.schedule;

import com.adventnet.ncm.util.NCMServerUtil;
import java.io.;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.
;

public class ScheduleResultViewerServlet extends HttpServlet
{

public ScheduleResultViewerServlet&#40;&#41;
{
    logger = Logger.getLogger&#40;com/adventnet/ncm/client/schedule/ScheduleResultViewerServlet.getName&#40;&#41;&#41;;
}

public void service&#40;HttpServletRequest request, HttpServletResponse response&#41;
    throws ServletException, IOException
{
    FileInputStream in;
    OutputStream out;
    in = null;
    out = null;
    try
    {
        String fileName = request.getParameter&#40;&quot;FileName&quot;&#41;; //&lt;--------------------------------------
        if&#40;fileName.endsWith&#40;&quot;.pdf&quot;&#41;&#41;
        {
            response.reset&#40;&#41;;
            response.setContentType&#40;&quot;application/pdf;charset=utf-8&quot;&#41;;
        } else
        {
            response.setContentType&#40;&quot;text/html;charset=utf-8&quot;&#41;;
        }
        File file = new File&#40;&#40;new StringBuilder&#40;&#41;&#41;.append&#40;NCMServerUtil.SERVER_HOME&#41;.append&#40;FS&#41;.append&#40;fileName&#41;.toString&#40;&#41;&#41;; //&lt;-----------------------
        response.setContentLength&#40;&#40;int&#41;file.length&#40;&#41;&#41;;
        in = new FileInputStream&#40;file&#41;;
        out = response.getOutputStream&#40;&#41;; //&lt;---------------------
        byte buf[] = new byte[1024];
        for&#40;int count = 0; &#40;count = in.read&#40;buf&#41;&#41; &gt;= 0;&#41;
            out.write&#40;buf, 0, count&#41;; //&lt;-----------------

    }
    catch&#40;Exception ex&#41;
    {
        logger.log&#40;Level.SEVERE, &quot;Exception while processing request in ScheduleResultViewerServlet&quot;, ex&#41;;
        throw new ServletException&#40;ex&#41;;
    }
    if&#40;in != null&#41;
        in.close&#40;&#41;;
    if&#40;out != null&#41;
        out.close&#40;&#41;;
    break MISSING_BLOCK_LABEL_221;
    Exception exception;
    exception;
    if&#40;in != null&#41;
        in.close&#40;&#41;;
    if&#40;out != null&#41;
        out.close&#40;&#41;;
    throw exception;
}

Logger logger;
private static final String FS = System.getProperty&#40;&quot;file.separator&quot;&#41;;

}

'FileName' is taken from the request parameter without sanitization then
is passed to the File object. File content is showed to the remote user.

I think this is a huge vulnerability because this could open the path to
the equipments of an entire network.

As attachment, proof of concept code, which backup the underlying Mysql
database. You could also choose to add your own file to the list,
launch from the command line, place inside a writable folder.

poc: http://retrogod.altervista.org/9sg_me_poc.htm