Skip to content
XSS Write-up Beginner

How I found an XSS in a Logbook System(Inline Code)

A logbook search parameter was reflected unescaped into an HTML input's value attribute, letting an attacker break out of the attribute and add an autofocus/onfocus handler. A victim who opened a crafted link would run the attacker's JavaScript automatically, which could steal session cookies or perform actions as the victim.

medium.com

Published on medium.com

While exploring the search functionality of a web application, I discovered a Reflected Cross-Site Scripting (XSS) vulnerability. In this post, I will walk through the discovery, the payload used, and how developers can prevent such flaws.

Mohamed Algabry, 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 inserted the search parameter into an HTML attribute without context-aware output encoding, so a double quote could close the attribute and new attributes could be added.

Impact

If a logged-in user opens the crafted link, the attacker's JavaScript runs automatically and could steal session cookies, show a fake login form, or make API calls as the victim.

What the attacker needed

Victim clicks a crafted link; victim is logged in

The fix

The report says the issue was patched; developers should also apply context-aware output encoding for HTML attributes and a strong Content Security Policy.

How it was found

  1. Open the logbook search page and notice the search value is reflected into the input's value attribute.
  2. Craft a URL whose search parameter starts with a double quote to close the value attribute.
  3. Add an autofocus attribute and an onfocus handler so the script runs without a click.
  4. Add a dummy attribute at the end to absorb the leftover quote.
  5. Send the crafted URL to a logged-in victim; the alert fires on page load.

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.

The search box put whatever you typed straight into the page's HTML without cleaning it. By typing a quote character, the author closed the box's setting and added a new instruction that runs code as soon as the page loads. That code runs in the victim's browser with their logged-in session, so it can read their cookies or act as them.

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.