The essence of all Cross-site scripting (XSS) attacks is unsanitized verbosity. In that respect every application that echoes input is vulnerable and can be potentially exploited by attackers to steal session identifiers, trick the user into performing some malicious activity, gather important information, etc.

XSS attacks can be persistent and non-persistent. Persistent XSS is more dangerous since it allow attackers to control exploited clients for longer. On the other hand non-persistent XSS is considered less dangerous although it has been widely used in many phishing attempts.

In this article I will expose some of my findings around a new attack vector which is of type non-persistent XSS but a lot more dangerous than the persistent one. This method can be used to successfully bypass some mail filters, XSS filters, application firewalls and sanitization functions. In fact if you are previewing this post with an RSS reader that is vulnerable you may try clicking on the following link which will result in a harmless greeting alert box.

Some of you might be familiar with this attack vector; this subject has been covered very vaguely in the past and none of its full potentials has been explored. The impact of this attack is much bigger today and could affect many web applications.

The name “Self-contained XSS” explains it all. It is a Cross-site scripting attack that does not require vulnerable web resource to echo input. Everything that is needed is contained in a single URL. Once this URL is executed the resource will be automatically assembled.

The URL must be prefixed with the data: protocol and follow special syntax. There are many protocols in modern browsers such as http:, https:, ftp: and about: but data: seams to be the most functional one because it could potentially enable rich AJAX applications to generate PDF, DOC, MP3, etc formats without the need of server side scripts. The specifications of this protocol were outlined 1998 rfc2397 from Xerox Corporation.

The following example demonstrates the enormous capabilities of the data: url schema and also outlines the possible security risks. In the text area bellow you will be able to generate html payloads that can be opened and executed.


The impact of Self-contained XSS is even bigger than one can imagine. This technique allows dynamic creation of binary files from JavaScript. JavaScript worms are now able to create DOC and PDF files that may contain malicious payload for exploiting various overflow vulnerabilities. For example the following link opens a Self-contained word document which luckily is absolutely harmless.

This issue is mainly related to Firefox, Opera and probably other browsers. IE6 and IE7 are not affected in that respect although it is believed that there might be other means of achieving the same result. Keep in mind that this is not a vulnerability but rather a feature.

My research shows that too many applications are vulnerable to Self-contained XSS attacks. Applications from Google, Yahoo, MSN and Live, Youtube and many more may fall into this group.

It is important to understand that this attack vector can be exploited on a massive scale so standard practices for testing for this issue must be implemented and included in all web application testing procedures.