Cross Site Scripting (XSS) : Troy Hunt @troyhunt
Cross Site Scripting (XSS) : Troy Hunt @troyhunt
Troy Hunt
troyhunt.com
@troyhunt
Outline
Trusted Trusted
www.mysite.com/Search?q=ferrari
Markup
www.mysite.com/Search?q=ferrari<i>enzo</i>
The search term was never intended to be markup, only ever data
XSS attacks are possible because the app allows an XSS payload to
break out of the data context and change the markup context
To mitigate the risk of XSS, we want to make sure the search term
appears on the screen exactly as it was entered
So how do we write markup to display “<i>enzo</i>” on the screen?
<i>enzo</i>
Output encoding contexts for “<i>enzo</i>”
HTML <i>enzo</i>
CSS \<i\>enzo\</i\>
JavaScript '\x3ci\x3eenzo\x3c\x2fi\x3e'
URL \00003Ci\00003Eenzo\00003C\00002Fi\00003E
LDAP distinguished name \<i\>enzo\</i\>
HTML attribute, HTML form URL, LDAP filter, URL path, XML, XML
attribute
Summary