Skip to content
XSS Write-up Beginner

Discovering a Stored XSS Vulnerability in a Blog Feature (Respons

A blog posting feature rendered user-supplied HTML without sanitisation or encoding, allowing an attacker to store a script that executes in the browser of anyone who views the post. The author demonstrated this with an image tag carrying an error handler that ran JavaScript when the post was loaded.

teman das Follow

Published on medium.com

Cross-Site Scripting (XSS) is one of the most common web vulnerabilities that allows attackers to inject malicious scripts into web pages viewed by other users.

teman das, 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 saved user input and inserted it directly into the page's HTML without output encoding or sanitisation, so browser-interpreted markup and event handlers were treated as code.

Impact

An attacker could run scripts in visitors' browsers, which may lead to session hijacking if cookies are accessible, account takeover especially if an admin views the page, and phishing through fake UI elements.

What the attacker needed

Ability to create or edit a blog post; victim views the published post

The fix

The application should encode special characters before rendering, sanitise dangerous HTML tags and attributes, use a sanitiser library, apply a Content Security Policy, and set HttpOnly and Secure cookie flags.

How it was found

  1. Open the blog post creation feature and enter content into an input field.
  2. Submit a simple HTML tag with an error handler as the post content.
  3. Observe that the application accepts and renders the input without validation.
  4. View the published blog post and see the JavaScript execute in the browser.

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 a website lets you type something and later shows it to other people, it must treat that text as plain text, not as code. Here the site saved the text and then inserted it into the page as if it were part of the website's own code, so a small piece of code hidden in a blog post ran in every visitor's browser. That kind of stored code injection is called stored cross-site scripting.

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.