Showing posts from June, 2012

XSS: Gaining access to HttpOnly Cookie in 2012

Update 2016/02:
We were asked by a lot if this still works.  Shortly after our disclosure, this issue has been patched.

The Background - The Past
Gaining access to HttpOnly cookie was first attempted by means of XST, Cross Site Tracing vulnerability.

Soon after the popularity of XST, the TRACE method has been disabled by most web servers.  Later, browsers' implementation of XMLHttpRequest also blocked "TRACE" method (i.e.'TRACE', url, true)].  Later, a flawed implementation in Firefox's XMLHttpRequest which can be used to access set-cookie response header was fixed.  

JS Debugger pointing out "TRACE" method as invalid arugment
JS Debugger pointing out "TRACE" method as illegal value
A forum member, LeverOne, posted ways to access HttpOnly cookie through the use of Java API and applet.  I reproduced his techniques. When the first method was tried, the Java Runtime did not allow the HTTP TRACE method any more. …

Using POST method to bypass IE-browser protected XSS

Up until now,  XSS prevention has been built in some popular browsers: Chrome, Safrai and Internet Explorer 8+.

We found Chrome and Safari prevent both POST and GET-based XSS.

Unfortunately, IE does not prevent POST-based XSS.

HttpOnly Session ID in URL and Page Body | Cross Site Scripting

The Background

We have been seeing authentication session ID appeared in URL Query String/REST URI and page body.  The use of session ID in Query String is to enable session tracking for web browsers which disable or do not support browser-based cookie mechanism.  This is commonly seen in Java web applications and cookieless mechanism in web applications.

From what we have seen so far, the session ID in page body is used as anti Cross Site Request Forgery token or anti-cache parameter though it is not very common.

The Problem

It should be noted that even though developers use the "HttpOnly" session cookie,  the above-mentioned  leakages of session ID in URL and page body nullify the effectiveness of "HttpOnly" flag.  This no doubt leads attackers to gain access to the HttpOnly session cookie via an Cross Site Scripting (XSS) vulnerability as JavaScript can read anything in the page body and URL information.