Reflected DOM XSS Vulnerability via eval() Leading to alert()
A reflected DOM XSS vulnerability exists because the search results script reads the search term from the URL and passes it to eval() without sanitisation. An attacker could craft a link that executes arbitrary JavaScript in the victim's browser.
medium.com
Published on medium.com
Reflected DOM XSS occurs entirely on the client side, within the browser. It involves unsafe handling of data that is reflected from the URL or user input into the page’s DOM (Document Object Model), and then passed to a dangerous sink, such as eval().
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
Impact
Attackers could steal session cookies if the site lacks HttpOnly flags and redirect users to phishing sites without their consent.
What the attacker needed
Victim clicks a crafted link
How it was found
- Open the DOM XSS lab.
- Enter a harmless HTML element in the search bar.
- Inspect the HTTP history in Burp Suite to see the JavaScript using eval().
- Send the request to Burp Repeater for closer inspection.
- Craft a breakout payload to escape the JSON string and reach the eval() context.
- Trigger alert(1) by executing the payload through the main website's search form.
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 you type something into a search box, the website sometimes puts your text directly into the page's code. Here, the site took the search term and ran it as JavaScript using a function called eval(), which executes any code it is given. Because the search term was not cleaned, an attacker could make a link that runs their own code when clicked.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.