JavaScript's Built-In Function(s) --- A Potential XSS Venue
User-supplied input was reflected unescaped inside JavaScript built-in function calls such as decodeURI, replace and window.location.replace on several sites. An attacker could break out of the string context and execute arbitrary JavaScript, achieving reflected XSS.
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 application inserted user-controlled input into a JavaScript string literal without escaping quotes or other syntax characters, so the input could terminate the string and inject code.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser through a crafted link, though the author notes that some payload variants were blocked by filtering or encoding.
What the attacker needed
Victim clicks a crafted link; reflected input in a JavaScript function
The fix
The application should escape or encode user input before placing it inside JavaScript string literals, or avoid inserting user input into script code altogether.
How it was found
- Send a probe string containing a single quote and other characters in a URL parameter.
- Observe that the probe is reflected inside a JavaScript function call such as decodeURI.
- Craft a payload that closes the string and the function call, then adds a confirm(1) call.
- Use a comment or extra characters to avoid a syntax error.
- Load the crafted URL and see the JavaScript execute.
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.
Some websites put what you type in the address bar directly into a piece of JavaScript code on the page. If the site does not clean that text properly, an attacker can add extra characters that end the string early and run their own JavaScript. This lets the attacker run 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.