search menu icon-carat-right cmu-wordmark

CERT Coordination Center

Jetty HTTP server directory traversal vulnerability

Vulnerability Note VU#402580

Original Release Date: 2009-05-01 | Last Revised: 2009-05-02

Overview

A vulnerability in the Jetty HTTP server could allow a remote attacker to gain access to files outside of the normal document tree.

Description

Jetty provides an HTTP server, HTTP client, and javax.servlet container. An error in the way canonical paths are interpreted in the HTTP server's URI handler results in a directory traversal vulnerability. This vulnerability affects all versions of Jetty up to and including jetty 6.1.16 and 7.0.0.M2. In order for a system to be vulnerable, it must either be using the DefaultServlet with support for aliases explicitly enabled or the ResourceHandler class to serve static content. The vendor reports that systems running Jetty on Unix-like operating systems must also contain a directory name ending a '?' character in the web application or document root in order to be vulnerable.

Impact

A remote attacker can access files outside of the web application or document root by supplying a crafted URL to an vulnerable system.

Solution

Upgrade or apply a patch from the vendor

Jetty version 6.1.17 has been published to address this vulnerability. Users are encouraged to upgrade to this version.

The vendor has described the following workarounds for users who are unable to update their software:


If you are not using the ResourceHandler, then you should
confirm that your jetty instance is running with
the Default servlet "aliases" initParam set to "false".
You will find this setting in either your application's
web.xml or the etc/webdefault.xml. If it is not set,
then it takes the default, safe, value of "false".
You should also check that the org.mortbay.util.FileResource.checkAliases
system property is either not set, or set to true.

If you are using the ResourceHandler, then you can secure your
system against this vulnerability by compiling the source
at the bottom of this message against the version of Jetty
that you are using.  Use an instance of this class instead
of the ResourceHandler


package org.mortbay.jetty.cert;
import java.net.MalformedURLException;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.resource.Resource;
import org.mortbay.util.StringUtil;
import org.mortbay.util.URIUtil;
public class TempFixResourceHandler extends ResourceHandler
{
    public Resource getResource(String path) throws MalformedURLException
    {
        if (path!=null && path.indexOf('?')>=0)
        {
            path=URIUtil.decodePath(URIUtil.canonicalPath(StringUtil.replace(path,"?","%3F")));
            if (path==null)
                return null;
        }
        return super.getResource(path);
    }
}

Vendor Information

Systems using Jetty versions 6.1.16 and earlier, and versions 7.0.0M2 and earlier.

402580
 
Affected   Unknown   Unaffected

Mort Bay

Updated:  May 01, 2009

Statement Date:   April 29, 2009

Status

  Vulnerable

Vendor Statement

A security vulnerability has been discovered in jetty that effects

all version of Jetty up to and including jetty 6.1.16 and 7.0.0.M2
On a vulnerable server, a crafted URL may access files outside of
the web application or document tree.

To be vulnerable to this issue, you must EITHER:

 - be using the DefaultServlet with support for aliases
   explicitly turned on.

   OR

 - be using the ResourceHandler class to serve static content.

Furthermore, on unix systems, system are only vulnerable if a directory
with a name ending with the character '?' to exist in the webapp or
docroot. On unix, this is an unlikely situation.

On windows systems, this directory does not need to exist, so the
vulnerability requires only a single change from the default
configuration.

A 6.1.17 release will be available shortly with this vulnerability
closed.  Some immediate preventative actions are listed below.

If you are not using the ResourceHandler, then you should
confirm that your jetty instance is running with
the Default servlet "aliases" initParam set to "false".
You will find this setting in either your application's
web.xml or the etc/webdefault.xml. If it is not set,
then it takes the default, safe, value of "false".
You should also check that the org.mortbay.util.FileResource.checkAliases
system property is either not set, or set to true.

If you are using the ResourceHandler, then you can secure your
system against this vulnerability by compiling the source
at the bottom of this message against the version of Jetty
that you are using.  Use an instance of this class instead
of the ResourceHandler


package org.mortbay.jetty.cert;
import java.net.MalformedURLException;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.resource.Resource;
import org.mortbay.util.StringUtil;
import org.mortbay.util.URIUtil;
public class TempFixResourceHandler extends ResourceHandler
{
    public Resource getResource(String path) throws MalformedURLException
    {
        if (path!=null && path.indexOf('?')>=0)
        {
            path=URIUtil.decodePath(URIUtil.canonicalPath(StringUtil.replace(path,"?","%3F")));
            if (path==null)
                return null;
        }
        return super.getResource(path);
    }
}

Vendor Information

http://docs.codehaus.org/display/JETTY/Jetty+Security

http://jira.codehaus.org/browse/JETTY-1004


CVSS Metrics

Group Score Vector
Base N/A N/A
Temporal N/A N/A
Environmental N/A

References

Acknowledgements

Thanks to Greg Wilkins of Mort Bay Consulting for reporting this vulnerability.

This document was written by Chad R Dougherty.

Other Information

CVE IDs: None
Severity Metric: 6.60
Date Public: 2009-04-29
Date First Published: 2009-05-01
Date Last Updated: 2009-05-02 01:28 UTC
Document Revision: 9

Sponsored by the Department of Homeland Security Office of Cybersecurity and Communications.