jetty 6.x < 7.x - Cross-Site Scripting / Information Disclosure / Injection







Jetty 6.x and 7.x Multiple Vulnerabilities

 Name              Multiple Vulnerabilities in Jetty
 Systems Affected  Jetty 7.0.0 and earlier versions
 Severity          Medium
 Impact (CVSSv2)   Medium 5/10, vector: (AV:N/AC:L/Au:N/C:P/I:N/A:N)
 Authors           Francesco "ascii" Ongaro (ascii AT ush DOT it)
                   Giovanni "evilaliv3" Pellerano (evilaliv3 AT ush DOT it)
                   Antonio "s4tan" Parata (s4tan AT ush DOT it)
 Date              20091024


Jetty is an open-source project providing a HTTP server, HTTP client and
javax.servlet container. These 100% java components are full-featured,
standards based, small foot print, embeddable, asynchronous and
enterprise scalable. Jetty is dual licensed under the Apache Licence
2.0 and/or the Eclipse Public License 1.0. Jetty is free for commercial
use and distribution under the terms of either of those licenses.

Jetty is used in a wide variety of projects and products: embedded in
phones, in tools like the the eclipse IDE, in frameworks like GWT, in
application servers like Apache Geronimo and in huge clusters like
Yahoo's Hadoop cluster.

The latest version at the time of writing can be obtained from:

Running Jetty 7.0.x is very easy, from the documentation page at:

- From an unpacked release directory of jetty-7,
  the server can be started with the command: java -jar start.jar

- This will start a HTTP server on port 8080 and
  deploy the test web application at: http://localhost:8080/test


Multiple Vulnerabilities exist in Jetty software.



 A) "Dump Servlet" information leak
    (Affected versions: Any)

 B) "FORM Authentication demo" information leak
    (Affected versions: Any)

 C) "JSP Dump" reflected XSS
    (Affected versions: Any)

 D) "Session Dump Servlet" stored XSS
    (Affected versions: Any)

 E) "Cookie Dump Servlet" escape sequence injection
    (Affected versions: Any)

 F) Http Content-Length header escape sequence injection
    (Affected versions: Any)

 G) "Cookie Dump Servlet" stored XSS
    (Affected versions: =<6.1.20)

 H) WebApp JSP Snoop page XSS
    (Affected versions: =<6.1.21)

A) "Dump Servlet" information leak
   (Affected versions: Any)

By requesting the demo "Dump Servlet" at an URL like "/test/dump/"
it's possible to obtain a number of details about the remote Jetty

Variables: getMethod, getContentLength, getContentType, getRequestURI,
getRequestURL, getContextPath, getServletPath, getPathInfo,
getPathTranslated, getQueryString, getProtocol, getScheme,
getServerName, getServerPort, getLocalName, getLocalAddr,
getLocalPort, getRemoteUser, getRemoteAddr, getRemoteHost,
getRemotePort, getRequestedSessionId, isSecure(), isUserInRole(admin),
getLocale, getLocales, getLocales

Plus a dump of all the HTTP request headers, the request parameters
and much more.

Five forms can be used to perform a series of functionality tests

  - Form to generate GET content
  - Form to generate POST content
  - Form to generate UPLOAD content
  - Form to set Cookie
  - Form to get Resource

While this is a feature we think that demo utilities should be
disabled by default. Many live deployments of Jetty exhibit demo
pages that leak important information and expose several vulnerabilites.

B) "FORM Authentication demo" information leak
   (Affected versions: Any)

An example application often erroneously deployed is the "FORM
Authentication demo" (logon.html and logonError.html pages) that uses
the standard "j_security_check" component.

By requesting the "/test/logon.html" page it's possible to detect the
presence of a Jetty installation.

As noted before we think that demo utilities should be disabled by

C) "JSP Dump" reflected XSS
   (Affected versions: Any)

It has been found that the demo "JSP Dump" feature is vulnerable to
reflected Cross Site Scripting attacks. This can be replicated by
issuing a GET request to the "/test/jsp/dump.jsp" page:

Any GET key and value that reach the remote is reflected unencoded.

The problem resides in the "jsp/dump.jsp" file from the
"webapps/test.war" archive.


<%@ page import="java.util.Enumeration" %>
<h1>JSP Dump</h1>

<table border="1">
<tr><th>Request URI:</th><td><%= request.getRequestURI() %></td></tr>
<tr><th>ServletPath:</th><td><%= request.getServletPath() %></td></tr>
<tr><th>PathInfo:</th><td><%= request.getPathInfo() %></td></tr>

   Enumeration e =request.getParameterNames();
       String name = (String)e.nextElement();
  <th>getParameter("<%= name %>")</th>
  <td><%= request.getParameter(name) %></td></tr>
<% } %>



As shown no encoding is applied to user inputs.

D) "Session Dump Servlet" stored XSS
   (Affected versions: Any)

It has been found that the "Session Dump Servlet" feature is affected
by a stored Cross Site Scripting vulnerability.

The servlet, mapped in "/session/", normally uses HTTP POST parameters
but also accepts values by HTTP GET granting easier exploitation.

The issue can be verified by requesting an URL like the following:

Any consecutive request to "/test/session/" without parameters will
include the previously inserted payloads.

Session keys and values are reflected unencoded both on the first and
successive requests.

E) "Cookie Dump Servlet" escape sequence injection
   (Affected versions: Any)

Making a POST request to the form at "/test/cookie/" with the "Age"
parameter set to a string throws a "java.lang.NumberFormatException"

The backtrace output is not sanitized from escape sequences, this
vulnerability is similiar to CVE-2003-0020 [1] and CVE-2003-0083 [2].

While the backtrace is protected from Cross Site Scripting attacks it
still reflects as-is many binary characters including ESC. These special
characters are used in control sequences to instruct the terminal to
perform special operations like executing commands [3, 4] or dumping
the buffer to a file [5, 6].

This issue can be demonstrated with the following Proof of Concept using
a non-dangerous escape sequence that will change the Xterm title.

In the first terminal:
$ echo -en "\x1b]2;safe?\x07\x0a"; java -jar start.jar etc/jetty.xml;

In the second terminal:
$ curl -kis "http://localhost:8080/cookie/" -d "Action=Set&Name=aa&Value

Logs can be found in logs/[date].stderrout.log or are printed directly
to the terminal. A user that views (cat, tail -f) these logs or runs
Jetty in his tty/pty may get influenced in a negative way by a malicious
control sequence.

The code involved in this vulnerability is in the Java class found at


    protected void handleForm(HttpServletRequest request,
                          HttpServletResponse response)
        String action = request.getParameter("Action");
        String name =  request.getParameter("Name");
        String value =  request.getParameter("Value");
        String age =  request.getParameter("Age");

        if (name!=null && name.length()>0)
            Cookie cookie = new Cookie(name,value);
            if (age!=null && age.length()>0)


The problem also exists for other demo pages, see for example the
"/test/jsp/expr.jsp" page (eg: "/test/jsp/expr.jsp?A=LetteralString").

This issue is generic to all the Java applications that use the standard
error handling mechanism. Consider this an advisory also for Java JVM.

F) HTTP Content-Length header escape sequence injection
   (Affected versions: Any)

The same attack vector presented in point "E" can be exploited by
requesting a page using an HTTP request "Content-Length" header set to
a letteral string. This raises a type mismatch exception as previously
shown. See the following PoC:

$ curl -H "Content-Length: abcde"

The difference between this possibility and the one exposed in "E" is
that this works not only on Jetty default demo applications but on every
application that Jetty will serve.

G) "Cookie Dump Servlet" stored XSS
   (Affected versions: =<6.1.20)

On Tue, 06 Oct 2009 the CORE-2009-0922 advisory killed part of our
research. The advisory titled "Jetty Persistent XSS in Sample Cookies
Application" is about this specific point.

Out initial writing is presented anyway:

The "Cookie Dump Servlet" works in a similar way as the previous "Session
Dump Servlet", accepting GET parameters. The difference is that two
requests are needed (as it was a stored POST XSS) since the first will
trigger the Set-Cookie and the second request will echo it. This issue
can be replicated with the following request:


Input values are stored and presented unescaped.

H) WebApp JSP Snoop page XSS
   (Affected versions: =<6.1.21)

All the Jetty 6.1.X versions are affected by a reflected XSS in the JSP
Snoop page. This does not work on the 7.X branch.

When called by it's deploy the "WebApp JSP Snoop page" (/jspsnoop) is
vulnerable to XSS:


"Path translated" and "Path info" are not encoded.

This in not exploitable when the page is implicitly called, for example
to handle a 404 page as the "Path translated" is always "/ERROR/404".
The same happens when requiring the page by its filesystem location


Jetty 7.0.0 and possibly earlier versions are vulnerable.

Jetty can be identified using the following examples or by directly
requesting files and locations marked as "information leak" in this

Some examples:

  - intitle:"Powered By Jetty"
  - intitle:"JSP snoop page" "WebApp JSP Snoop page"
  - inurl:"snoop.jsp
  - "Welcome to Jetty 7"


The vendor decided not to modify the release schedule in order to
publish a version to address the presented issues. We have been sayd
that the next release (available in 1 to 3 weeks) will resolve all the
issues in the demo applications and the command sequence injection

The ESC insertion problems will be resolved by:

- Handling the particular exceptions you found (NumberFormateException).
- Updating the stderrlogger so that all user supplied output is stripped
  of non whitespace ISO control characters.
- Stripping ISO control characters from generated error pages.

In the meantime the vendor provides the following workaround

- The test webappplications must not be deployed on production sites.
  An administrator can remove the "webapps/test.war" file and/or the
  "webapps/test directory", plus the contexts/test.xml file.

- Do not run Jetty as the root user. Instead run as a limited
  user and redirect port 80 to the port that jetty is using.

- Do not run production jetty instances from a console. Instead
  start in the background using an /etc/init.rc/ script
  or similar.

- Redirect stderr to a file. This can be done with the jetty-logging.xml
  file as follows:
  java -jar start.jar etc/jetty.xml etc/jetty-logging.xml

- Process log files with cat -v if you wish to display them on a
  console without using an editor.


Vendor will not release a new version to address these issues but is
working on them in the SNAPSHOT versions.

We had no precise response about remediation status and plans but we
were told that it was okay to release this advisory. It elapsed about
a week from the last email sent to the vendor, since we got no reply
we assume that it's okay to release.


No CVE at this time.


20090616 Bug discovered
20091006 CORE-2009-0922 reveals an XSS issue (point G)
20091006 Jetty branch 7 kills the "jspsnoop" issue (point H)
20091011 Internal version of this advisory finalized
20091013 First vendor contact
20091014 Vendor Response, "We are working on XSS on demo apps"
20091015 Asking for release timeline
20091015 Vendor Response, Suggests a remediation, "Okay to release"
20091015 Remediation doesn't fix the Escape Sequence issue
20091015 Vendor Response, ACK, "Wait until next week"
20091016 Vendor Response, "We are not going to rush out a release to
fix the escape injection problem"
20091024 Advisory release


[1] Apache does not filter terminal escape sequences from error logs
[2] Apache does not filter terminal escape sequences from access logs
[3] Debian GNU/Linux XTERM (DECRQSS/comments) Weakness Vulnerability
[4] Terminal Emulator Security Issues
[5] Eterm Screen Dump Escape Sequence Local File Corruption Vulnerability
[6] RXVT Screen Dump Escape Sequence Local File Corruption Vulnerability


Francesco "ascii" Ongaro, Giovanni "evilaliv3" Pellerano and
Antonio "s4tan" Parata are credited with the discovery of this

Francesco "ascii" Ongaro
web site:
mail: ascii AT ush DOT it

Giovanni "evilaliv3" Pellerano
web site:,
mail: evilaliv3 AT ush DOT it

Antonio "s4tan" Parata
web site:
mail: s4tan AT ush DOT it


Copyright (c) 2009 Francesco "ascii" Ongaro

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without mine express
written consent. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically,
please email me for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.