jupenur/jqm-xss.md
jQuery Mobile fails to validate the content-type of XHR responses, allowing an attacker to inject HTML and JavaScript via a crafted URL that causes the library to load a same-origin API response containing user input. Additionally, a broken URL parser incorrectly treats different domains as same-origin, enabling XSS in versions up to 1.2.1.
gist.github.com
Published on gist.github.com
Clone this repository at <script src="https://gist.github.com/jupenur/e5d0c6f9b58aa81860bf74e010cf1685.js"></script> - Save jupenur/e5d0c6f9b58aa81860bf74e010cf1685 to your computer and use it in GitHub Desktop.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the library does not validate the content-type of XHR responses before inserting them into the DOM, and its URL parser incorrectly determines same-origin status.
Impact
An attacker could execute arbitrary JavaScript in the context of the vulnerable application, leading to data theft or other malicious actions; the exploit requires a same-origin API that reflects user input, and in versions >1.2.1 the XSS via broken URL parsing does not work.
What the attacker needed
JQuery Mobile included in a web application; same-origin API reflecting user input (for versions >1.2.1); victim clicks a crafted link
The fix
No official patch is available; migrate to an alternative framework if possible.
How it was found
- Craft a URL with a fragment containing a search query that includes an iframe with a javascript: URL.
- Victim opens the crafted URL.
- jQuery Mobile makes an XHR request to the search API with the malicious query.
- The API reflects the query in a JSON response.
- jQuery Mobile inserts the response into the DOM without checking content-type, executing the JavaScript.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
jQuery Mobile is a tool for building mobile websites. It can be tricked into loading data from a website and putting it directly into the page without checking if it's safe. This lets an attacker run their own code in the victim's browser, which is called cross-site scripting (XSS).
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.