Jetty Persistent XSS in Sample Cookies Application

Advisory ID Internal
CORE-2009-0922

1. Advisory Information

Title: Jetty Persistent XSS in Sample Cookies Application
Advisory Id: CORE-2009-0922
Date published: 2009-10-06
Date of last update: 2009-10-06
Vendors contacted: Jetty Team
Release mode: Coordinated release

2. Vulnerability Information

Class: Persistent Cross-site Scripting [CWE-79]
Impact: Code execution
Remotely Exploitable: Yes
Locally Exploitable: No
Bugtraq ID: N/A
CVE Name: N/A

3. Vulnerability Description

Jetty includes several sample web applications for the developer to learn from. One of them sets cookies with user supplied data, and then dumps them as html. This application does not filter the user supplied data when outputting it to the visitor. This constitutes a persistent XSS vulnerability [1].

This application accepts the cookie content as a GET parameter. This allows an attacker to trick someone into clicking a handcrafted link with malicious code as the cookie content, and thus executing that code in a privileged domain, such as localhost, any domain in the intranet zone, or a domain where another web application is running. 

4. Vulnerable packages

  • Jetty 6.1.19
  • Jetty 6.1.20

5. Non-vulnerable packages

  • Jetty 6.1.21
  • Jetty 7.0.0

6. Vendor Information, Solutions and Workarounds

A workaround is to disable this particular example on any running instance of Jetty in a particular workstation. Examples should always be disabled on production servers, as recommended by the software vendor.

7. Credits

This vulnerability was discovered by Aureliano Calvo from Core Security Technologies during Bugweek 2009 [2].

8. Technical Description / Proof of Concept Code

The problem resides in the CookieDump.java file from the examples.

 Cookie[] cookies = request.getCookies(); for (int i=0;cookies!=null && i<cookies.length;i++) { out.println("<b>"+cookies[i].getName()+"</b>="+cookies[i].getValue()+"<br/>"); } 

cookies[i].getValue() should be filtered to avoid malicious code from being executed.

9. Report Timeline

  • 2009-09-22: Core Security Technologies contacts Jan Bartel and Greg Wilkins from Webtide, notifying them of the existence of a XSS vulnerability in a sample application. Core sends its PGP key and asks Jan for his, would he like to keep future communications encrypted.
  • 2009-09-23: Greg Wilkins asks for technical information about the vulnerability in plaintext. He also comments that some vulnerabilities have been fixed in the 6.1.21 and 7.0 releases, and asks Core to verify if the reported vulnerability has already been fixed in their repositories.
  • 2009-09-23: Technical details are sent by Core, specifying that the Persistent XSS that was discovered has not been fixed in the repositories pointed to by Greg. Core asks for a release date for the fixed version of Jetty in order to release the advisory only when a fixed version is available.
  • 2009-09-24: Greg Wilkins acknowledges the vulnerability and confirms it will be fixed on release 7.0.0, due the week of September 28th. A release date for Jetty 6.1.22 is not yet scheduled. Greg mentions that the recommended workaround for production servers is not to deploy the example applications.
  • 2009-09-28: Core reminds Greg that a deadline for the release of this advisory has been set to Monday October 5th.
  • 2009-09-28: Greg Wilkins agrees with the proposed publication date, since there is a good workaround.
  • 2009-10-06: The advisory CORE-2009-0922 is published.

10. References

[1] http://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
[2] The author participated in Core Bugweek 2009 as member of the team "Bugged Coffee".

11. About CoreLabs

CoreLabs, the research center of Core Security Technologies, is charged with anticipating the future needs and requirements for information security technologies. We conduct our research in several important areas of computer security including system vulnerabilities, cyber attack planning and simulation, source code auditing, and cryptography. Our results include problem formalization, identification of vulnerabilities, novel solutions and prototypes for new technologies. CoreLabs regularly publishes security advisories, technical papers, project information and shared software tools for public use at: www.coresecurity.com/core-labs.

12. About Core Security 

Core Security develops strategic solutions that help security-conscious organizations worldwide develop and maintain a proactive process for securing their networks. The company's flagship product, CORE IMPACT, is the most comprehensive product for performing enterprise security assurance testing. CORE IMPACT evaluates network, endpoint and end-user vulnerabilities and identifies what resources are exposed. It enables organizations to determine if current security investments are detecting and preventing attacks. Core Security augments its leading technology solution with world-class security consulting services, including penetration testing and software security auditing. www.coresecurity.com.

13. Disclaimer

The contents of this advisory are copyright (c) 2009 Core Security Technologies and (c) 2009 CoreLabs, and may be distributed freely provided that no fee is charged for this distribution and proper credit is given.