if --- Reflection Point
The report describes how user input reflected inside a JavaScript conditional statement can lead to XSS if not properly encoded. An attacker could inject JavaScript that executes when the condition is evaluated, as demonstrated with a confirm dialog.
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 failed to properly encode or filter single quotes when reflecting user input inside a JavaScript conditional statement.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, potentially leading to session hijacking or other malicious actions.
What the attacker needed
Victim clicks a crafted link
The fix
The application should properly encode or filter user input when reflecting it inside JavaScript contexts.
How it was found
- Open the URL with a probe string containing a single quote in the q parameter.
- Observe that the single quote is reflected unencoded inside a JavaScript if statement.
- Inject a payload that breaks out of the string and calls confirm(1).
- The confirm dialog executes, demonstrating XSS.
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 your input directly into a JavaScript if statement without cleaning it, you can break out of the string and run your own code. This is called cross-site scripting (XSS). The author shows a real site where typing a special character allowed a pop-up to appear.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.