Hades
jQuery-facilitated XSS
Last updated
jQuery-facilitated XSS
Last updated
Don't stop retrying!
This is basically a site that uses jQuery a bunch of AJAX requests to dynamically load the page content. For example, let's load the "news" category at ?cat=news
.
Observing the HTML response, the news
string is reflected twice in the JavaScript.
Trying to use a single quote to break out of the string (/?cat=news'
) doesn't work - a \
is prepended to it.
After doing some testing, I found that the \
character isn't escaped and /?cat=news\\'
breaks out of the string.
However, because any ()
characters are removed and subsequent quotes are still escaped, I couldn't produce valid JavaScript after breaking out of the string.
It seems that we need to find another way to achieve XSS.
The first line of the JavaScript tells jQuery to fetch /ajax/articles?cat=news
and set its contents as the HTML of the #ajax-load
element.
Because we also control the cat
parameter in this second request, we can try to find a HTML injection vector in /ajax/articles
and inject it into #ajax-load
.
The following request
injects an attribute into the <img>
element in the response.
Looking at jQuery's .load()
documentation, we find an interesting feature that allows us to specify a specific portion of the remote document that we want to insert.
This allows us to get rid of the pesky <noscript>
tag end only load the <img>
element inside.
will render
and give us XSS.
We can use the following payload to steal the admin's cookie and get the flag.