Every website that uses jQuery Mobile, and has any open redirect anywhere is vulnerable to cross-site scripting (XSS) attacks.
The jQuery Foundationâ€™s jQuery Mobile project is an HTML5-based framework thatÂ allows users to design a single responsive web site or application that will work on all popular mobile devices and desktop systems.
According to the foundation, the jQuery Mobile is currently used on more than 150,000 active websites.Â TheÂ Google security engineer Eduardo Vela has discovered that the jQuery Mobile framework can expose websites to cross-site scripting (XSS) attacks in case they are affected also by an open redirect vulnerability.
A few months ago, Vela was searching for CSP bypassesÂ and noticed an interesting behavior of the jQuery Mobile. The jQuery Mobile would fetch any URL in the location.hashÂ and put it in innerHTML, this behavior would be exploited by an attacker under specific conditions. Â I thought that was pretty weird, so decided to see if it was vulnerable to XSS.
Vela started searchingÂ for XSS vulnerability and devised the following attack:
- jQuery Mobile checks if you have anything in location.hash.
- If your location.hash looks like a URL, it will try to set history.pushState on it, then it will do an XMLHttpRequest to it.
- Then it will just innerHTML the response.
The expert explained that despite the history.pushState should prevent XSS attacks, it is still possible to exploit such kind of flaws if the website is affected by an open redirect vulnerability.
Below the demo provided by Vela:
According to the expert,Â thereÂ are many websites vulnerable to such attacks because many organizations donâ€™t consider open redirects as security vulnerabilities, such kind of issues are present in major websites such as Google, YouTube, Facebook, Baidu, and Yahoo.
Now the bad news!
Vela reported the flaw to jQuery Mobile development team, but likely it will not be fixed due to the potential impact of a fix on the existing applications. The development team confirmed the risks to their users.
â€śThe jQuery Mobile team explained that they consider the Open Redirect to be the vulnerability, and not their behavior of fetching andÂ inlining,Â and that they wouldnâ€™t want to make a change because that might break existing applications. This means thatÂ there wonâ€™t be a patchÂ as far as I have been informed. The jQuery mobile team suggests to 403 all requests made from XHR that might result in a redirect.â€ť wrote Vela.
â€śThis means that every website that uses jQuery Mobile, and has any open redirect anywhere is vulnerable to XSS.â€ś
Vela is inviting experts to try to exploit the same XSS in the absence of theÂ open redirect vulnerability, he already tested it but without success.
â€śOne opportunity for further research, if you have time in your hands is to try to find a way to make this bug work without the need of an Open Redirect. I tried to make it work, but it didnâ€™t work out,â€ť added Vela.
â€śIn my experience, Open Redirects are very common, and they are also a common source of bugs. Perhaps we should start fixing Open Redirects. Or perhaps we should be more consistent on not treating them as vulnerabilities. Either way, for as long as we have this disagreement in our industry, we at least get to enjoy some XSS bugsâ€ť