Keep An Eye On $.html, $.get and $.ajax Functions
The article describes three real-world examples where user input is reflected unsafely inside jQuery functions ($.html, $.get, $.ajax), allowing an attacker to inject script. The author demonstrates that a probe string containing a single quote or double quote breaks out of the JavaScript string context, enabling execution of a confirm dialog as proof of concept.
Published on respectxss.blogspot.com
The original lives on respectxss.blogspot.com
We do not hold its text, 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 developers inserted user-controlled input directly into JavaScript string literals without escaping quotes or encoding, so the input can terminate the string and inject code.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser when the victim visits a crafted link, potentially stealing data or performing actions on behalf of the user.
What the attacker needed
Victim clicks a crafted link; no authentication needed
How it was found
- Open the search URL with a probe string containing a single quote and angle brackets.
- Observe that the single quote is reflected unescaped inside the $.html() call.
- Replace the probe with a payload that breaks out of the string and calls confirm(1).
- Repeat the same process for the $.get() example using a double quote.
- Repeat for the $.ajax() example using a single quote in the data section.
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.
When a website puts user input directly into a JavaScript function without cleaning it, an attacker can trick the browser into running their own code. This is called cross-site scripting (XSS). The author found three places where a simple quote character was enough to break out of the code and run a harmless alert.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.