Home

Exploiting POST-based XSSI

We know, more and more client-side attacks are dying. But sometimes, with introduction of new features, an unexploitable becomes exploitable. Yes, combined with the power of Service Worker, XSSI is no longer limited to GET requests. This essentially means we can also include resources with POST requests and CORS-safelisted headers. The idea is simple- intercept the request and modify to send no-cors POST request. For demonstration purpose, I’ve built a rough POC at https://cm2.

XSS with length restriction

There are situations where you can execute JavaScript but you’re limited to alert because it only allows limited number of characters. I recently saw a report on HackerOne with exact same situation- which is why I’m writing this post. The reporter managed to execute arbitrary JavaScript but made it somewhat complicated and required few user interactions. This drastically lessens the severity and no doubt, results in small reward. The more promising Proof of Concept in case of XSS, in my opinion, is to load external JavaScript from a domain under your control.

On-site Request Forgery

You might have heard of Server Side Request Forgery or SSRF, and probably already came across On-site request Forgery. Let’s call it OSRF for brevity and not to confuse with CSRF. This post aims to briefly explain what OSRF is and how it differs from SSRF, possible impacts and remedy. To begin with, SSRF is a type of vulnerability where an attacker is able to influence Servers to send crafted requests to their destined location.

Forging Content-Type Header With Flash

You might already know how you can forge HTTP request headers using flash. So, to keep it short, I’m talking about Content-Type only. Lately, I’ve been seeing tweets & reports about CSRF attack involving JSON data. In fact, I saw a tweet asking if it was safe to rely on Content-Type: application/json for CSRF protection. And, going through the replies, I found it was concluded safe- because browsers don’t yet support application/json in HTML form submission.

HackerOne XSSI – Stealing Multi Line Strings

I assume you already know what XSSI is. If not, here’s a brief introduction cited from Identifier based XSSI attacks Cross Site Script Inclusion (XSSI) is an attack technique (or a vulnerability) that enables attackers to steal data of certain types across origin boundaries, by including target data using SCRIPT tag in an attackerss Web page as below <!-- attacker's page loads external data with SCRIPT tag --> <SCRIPT src="http://target.

MS Edge – HTTP Access Control (CORS) Bypass

This is a short post about a vulnerability I had found in Microsoft Edge. TL;DR Edge failed to recognize HTTP Authentication information (i.e. Authorization Header) as credential information when sending fetch requests. So, if an application uses Basic or NTLM auth, Edge would send Authorization header in all fetch requests despite specifying not to include credentials. If you noticed, I explicitly specified not to include credentials. Yet, it was sent despite me specifying not to and you can see the response in console.
Referrer Policy

Referrer Policy

There are, atm, 5 different ways referrer policy can be delivered as defined by W3C. Setting referrer policy via meta is supported by all modern browsers (as shown above). The other ones, however, are new and aren’t widely supported or used. The HTML Standard defines the concept of referrerpolicy attributes which applies to several of its elements, for example: <a href="http://example.com" referrerpolicy="origin"> In general, the order in which these signals are processed are

Stealing CSVs Cross-domain

Back in 2008, Chris Evans found it was possible to steal data cross-domain in Firefox using script includes. We can still read his report at http://scary.beasts.org/security/CESA-2008-011.html In his own words: The modern web model permits remote domain <script> inclusion with no restrictions. If the remote data, which does not have to be script, has an effect on the evil domain doing the inclusion, you have a cross-domain data leak.

Stealing CSVs Cross-domain

January 19, 2018

Back in 2008, Chris Evans found it was possible to steal data cross-domain in Firefox using script includes. We can still read his report at http://scary.beasts.org/security/CESA-2008-011.html

In his own words:

The modern web model permits remote domain <script> inclusion with no restrictions. If the remote data, which does not have to be script, has an effect on the evil domain doing the inclusion, you have a cross-domain data leak.

The idea was to use JavaScript error messages combined with 302 redirect. In general, modern browsers replace JavaScript error messages with a generic message like “Script error” to prevent leaking of error messages to remote domain. In case of same domain, detailed JavaScript error messages can be read.

I’ve found the same issue in IE 11 but with a peculiar prerequisite: – The loading page (more precisely- Tab) must have its Developers Tools open (or previously opened).

Yes, it’s weird but it doesn’t work if Developers Tools is not open or previously opened. Few other prerequisites which are essential for script inclusion attacks are:

  1. The values must form valid JavaScript variable names
  2. The included data, as a whole, must form valid JavaScript code

The best error message to target is “blah is not defined”, referring to a textual name that is not currently bound to a variable. You can cross-domain steal data that is a single word in this manner. If the cross-domain data is CSV, e.g. “a, b, c”, you can steal the text of all three words by iteratively sourcing the script, noting the undefined variable name, defining it and repeating.

So, basically, we can steal contents of any CSV file as long as it meets above prerequisites. In fact, we can steal any type of data as long as it meets above prerequisites, not only CSVs. It is also possible to use different charsets to steal data as long as the included page doesn’t specify its own charset. This is shown in Gareth’s post which I’ve added in REFERENCES.

Since, Chirs Evan’s POC is no longer live and doesn’t showcase stealing multiple values/variables, I’ve set up a POC which supplements his one at http://cm2.pw/xssi?url=/redirect%3Furl%3Dhttp%3A%2f%2fraw.cm2.pw%2ftoken.csv

You can also play with it, supplying your own arguments like: http://cm2.pw/xssi?url=http://example.com/user_info.js&eval=alert(email)

Here’s a 15 seconds video I made for POC:

I reported it to Microsoft but since it requires Developer Tools be opened or had it opened, it was not considered for fix atm. However, as they said, it may be resolved in future version update.

There is another, still working, POC that Gareth found which works perfectly in MS Edge. If you’re interested, you can read about it at http://blog.portswigger.net/2016/11/json-hijacking-for-modern-web.html

To remediate the issue, developers or website owners can do one or any combination of

  • Switch to POST method
  • Use secret tokens as in CSRF Protection
  • Make URL unpredictable
  • Strict referer checking

If the data is supposed to be retrieved via ajax requests for further processing, one can also

  • Use Parser-Breaking syntax like for(;;)
  • Use custom HTTP header

Specifying correct Content-Type and X-Content-Type-Options: nosniff would also suffice to remediate the issue for this particular case. However, I wouldn’t consider it a strong fix as there are browsers which still don’t support X-Content-Type-Options.

Thanks

Special thanks to @albinowax for his feedback and thorough proof-reading.

REFERENCES:

http://www.mbsd.jp/Whitepaper/xssi.pdf http://scary.beasts.org/security/CESA-2008-011.html http://blog.portswigger.net/2016/11/json-hijacking-for-modern-web.html http://balpha.de/2013/02/plain-text-considered-harmful-a-cross-domain-exploit/