Skip to content
XSS Write-up Beginner

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.

Ashar Javed Follow

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

  1. Open the URL with a probe string containing a single quote in the q parameter.
  2. Observe that the single quote is reflected unencoded inside a JavaScript if statement.
  3. Inject a payload that breaks out of the string and calls confirm(1).
  4. 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.

More by Ashar Javed

View all

14 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.