Shopping Online Without Bump into an XSS vulnerability
A search results page reflected the query parameter into the page without proper sanitisation, relying only on a keyword filter that blocked words like alert and confirm. An attacker could craft a link that runs script in the victim's browser when the error event of an image element fires, bypassing the filter.
medium.com
Published on medium.com
Just like every week, I was finishing my tasks in the evening and getting ready to go for a walk. Then, I wanted to check if there were any discounts on shoes that I wanted to buy.
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
Root cause
Likely the query parameter was inserted into the page without proper output encoding, and the developer relied on a homemade keyword blocklist that could be bypassed with an event handler.
Impact
A crafted link from a trusted domain could run script in a visitor's browser and redirect them to a malicious site, though the author only demonstrated an alert and did not test further exploitation.
What the attacker needed
Victim clicks a crafted link; no login needed
The fix
The parameter should be properly output-encoded rather than filtered by a keyword blocklist, but the text does not say whether it was fixed.
How it was found
- Type a simple search term into the search box and submit it.
- Observe the results heading that echoes the search term.
- Try an HTML tag in the query parameter and inspect the page to see it rendered as markup.
- Try a script tag and note the keyword filter turns it into plain text inside a span.
- Try an image tag with a broken source and an error handler to trigger script.
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.
A reflected cross-site scripting (XSS) bug means a value you put in a web address is echoed back into the page as live code instead of plain text. Here the site tried to block dangerous words, but a different trick (an image that fails to load and runs code on that error) slipped past the filter, so a crafted link could run code in a visitor's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.