Skip to content
XSS Write-up Beginner

Identifying and Exploiting a Reflected XSS Vulnerability

A reflected XSS vulnerability existed because the application filtered angle brackets but not event handler attributes. An attacker could inject an event handler that executes JavaScript when the user interacts with the page, potentially stealing session cookies.

medium.com

Published on medium.com

As a cybersecurity enthusiast, every vulnerability I uncover is a new learning experience. Recently, I discovered a reflected cross-site scripting (XSS) vulnerability on www.example.com.

Pious James, 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 application only filtered angle brackets and URL-encoded characters, but failed to properly encode or block event handler attributes in HTML output.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser when the victim interacts with the page, potentially stealing session cookies.

What the attacker needed

Victim clicks a crafted link; victim interacts with the page (mouse move or click)

The fix

The application should properly encode or sanitise all user input before reflecting it into HTML, including attribute contexts, rather than only filtering angle brackets.

How it was found

  1. Test a basic image tag with an onerror handler to see if angle brackets are filtered.
  2. Try URL-encoding the payload to bypass filtering.
  3. Craft a payload without angle brackets using an event handler attribute.
  4. Inject the payload into the vulnerable parameter and observe it reflected in an HTML attribute.
  5. Move the mouse over the affected element to trigger the script and display the session cookie.

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) is when a website shows user input as part of its page without making it safe, so an attacker can make the site run their JavaScript. Here, the site blocked the characters < and > but forgot to block things like onmousemove, which can run code when you move your mouse. That let the attacker run code in the victim's browser and read their session cookie.

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.