Sending user controlled inputs to jQuery functions may lead to critical XSS

Hey all , Its been some time I am trying to learn the security vulnerabilities related to Javascript .jQuery is one of the most widely used library of javascript . We find it embedded it most of the web pages we see these days. During the learning phase I found a very good post regarding jquery functions that allow HTML Injection . Following is the link to that post:

[pastacode lang=”markup” manual=”https%3A%2F%2Fcode.google.com%2Fp%2Fdomxsswiki%2Fwiki%2FjQuery%0A” message=”” highlight=”” provider=”manual”/]

Its written by the developer of popular JS Analyzer tool Dominator, Stefano Di Paola .Thanks to him for such a great post. It took me some time to understand . With this blog post i will try to explain about the above post by Stefano related to jQuery sinks which allow HTML Injection .
Demo/Example: I wrote a comment box code for my blog website which post the comment message using the .load() function of jQuery to database. This comment box code grab the GET parameter value of current page using php code and use that value in the .load() function of jquery.

If you see the line 28 , there is php code that grab the GET parameter value . .load() is one of the jQuery function that allow HTML injection . So , I injected the payload in the url and

The payload executed successfully (the vulnerable code is fixed now )
Like .load() there are many functions that allow HTML Injection. Following are few of them:

[pastacode lang=”javascript” manual=”add()%20%2C%20constructor()%20%2C%20has()%20%2C%20init()%20%2C%20index()%20%2C%20wrapAll()%20%2C%20wrapInner()%20%2C%20wrap()%20%2C%20append()%20%2C%20prepend()%20%2C%20before()%20%2C%20after()%20%2C%20html()%20%2C%20replaceWith()%20%2C%20appendTo()%20%2C%20prependTo()%20%2C%20insertBefore()%20%2C%20insertAfter()%20%2C%20replaceAll()%20%0ASource%3A%20https%3A%2F%2Fcode.google.com%2Fp%2Fdomxsswiki%2Fwiki%2FjQuery” message=”” highlight=”” provider=”manual”/]

So, while pentesting web applications if you find a jQuery function which uses some user controlled input from some source like GET parameters, it may be vulnerable to XSS. I will try to update this post with more sinks/function of jQuery that allow HTML Injection. I would like to give credits to one more person , Mike Shema

[pastacode lang=”markup” manual=”http%3A%2F%2Fdeadliestwebattacks.com%2F2013%2F12%2F03%2Fselector-the-almighty-subjugator-of-elements%2F” message=”” highlight=”” provider=”manual”/]

(Visited 190 times, 1 visits today)

Leave A Comment

Your email address will not be published. Required fields are marked *