Cross-Site Scripting (XSS)

All of the data on this page is passed through Django's automatic escaping routine, which escapes the 5 key XML characters. You can find the escaping routine for Django 1.2.1 here.

This 5 character escaping is very common in templating engines, but it doesn't provide provide full protection. Take a look at the CSS examples and examples without quotes.


RULE #1 - HTML Escape Before Inserting Untrusted Data into HTML Element Content


Normal Element Content, common attacks are:
<span></span>
Source HTML: <span></span>
Rendered HTML:


RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes


Unquoted Attribute, common attacks are:
<span class=>test</span>
Source HTML: <span class=>test</span>
Rendered HTML: test


Quoted Attribute, common attacks are:
<span class="">test</span>
Source HTML: <span class="">test</span>
Rendered HTML: test


RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values


Unquoted value, common attacks are: Note that JavaScript escaping can be \A (ascii) or \xHH (hex) or \OOO (octal)
<img src="/img/favicon.ico" onload="var i=;">
Source HTML: <img src="/img/favicon.ico" onload="var i=;">
Rendered HTML:


Quoted value, common attacks are: Note that JavaScript escaping can be \A (ascii) or \xHH (hex) or \OOO (octal)
<img src="/img/favicon.ico" onload="var i=''">
Source HTML: <img src="/img/favicon.ico" onload="var i=''">
Rendered HTML:


RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values


Unquoted Style Attribute, common attacks are:
<span style=>test</span>
Source HTML: <span style=>test</span>
Rendered HTML: test


Quoted Style Attribute, common attacks are:
<span style="">test</span>
Source HTML: <span style="">test</span>
Rendered HTML: test


RULE #5 - URL Escape Before Inserting Untrusted Data into HTML URL Attributes


Unquoted URL attribute, common attacks are:
<a href=>test</a>
Source HTML: <a href=>test</a>
Rendered HTML: test


Quoted URL Attribute, common attacks are:
<a href="">test</a>
Source HTML: <a href="">test</a>
Rendered HTML: test