Skip to content
XSS Write-up Beginner

Today I Found an XSS Bug: A Lesson in Web Security

A search bar on a website reflected user input without sanitisation, so a script tag entered into it executed in the browser. An attacker could craft a link containing such a script and, if a victim clicked it, run code in the victim's browser to potentially steal cookies or session tokens.

medium.com

Published on medium.com

As an ethical hacker, my journey is filled with constant learning, challenges, and triumphs. But there are days when a single discovery makes everything feel worth it.

TheIndianNetwork, on medium.com

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 search bar reflected user input into the page without encoding special characters, so browser-executable markup was rendered instead of displayed as text.

Impact

An attacker could craft a malicious link containing the script and, if a victim clicked it, execute code in the victim's browser, potentially stealing cookies or session tokens.

What the attacker needed

Victim clicks a crafted link

The fix

The site should sanitise and encode user input before displaying it, for example with a library such as DOMPurify or OWASP Java Encoder.

How it was found

  1. Open the website and find the search bar.
  2. Enter a script tag into the search bar.
  3. Observe that the page renders the input and the script executes, showing an alert.

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.

Cross-Site Scripting (XSS) happens when a website takes text you type and puts it back on the page without cleaning it first. If that text includes code, the browser runs it as if the website itself had written it. Here, typing a script into the search bar made an alert box appear, showing the site was not cleaning the input.

What is XSS?

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

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.