Skip to content
XSS Write-up Beginner

Mastering Web Security: Exploiting Stored XSS into HTML Context

The blog comment feature stored user input and rendered it into the page without encoding, so a script tag in a comment executed in every visitor's browser. An attacker could run arbitrary JavaScript in the session of anyone viewing the post.

medium.com

Published on medium.com

Stored Cross-Site Scripting (XSS) is a high-impact vulnerability that occurs when an application saves untrusted user input and later reflects it to other users without proper validation or encoding. In this write-up, I will demonstrate how to exploit a Stored XSS vulnerability in a blog’s comment section…

Albert Simanjuntak, 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

The application rendered stored comment text into the HTML page without context-aware output encoding or sanitisation.

Impact

A single stored comment could execute script in the browser of every visitor who views that post, potentially compromising their sessions.

What the attacker needed

Ability to post a comment on a blog post

The fix

The application should apply context-aware output encoding when rendering stored comments, converting characters such as angle brackets into safe HTML entities.

How it was found

  1. Open a blog post and find the comment form.
  2. Enter a script tag as the comment.
  3. Fill in the name, email and website fields and post the comment.
  4. Return to the blog post and the stored script runs 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.

A blog let people post comments, and it saved whatever they typed and showed it on the page exactly as typed. If someone typed code that a browser treats as a program, the browser ran that program for every reader. This is called stored cross-site scripting because the harmful input is kept on the server and served to others.

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.