Skip to content
XSS Write-up Intermediate

Stored DOM XSS: A Hidden Threat in Blog Comments

A blog comment feature stored user input and rendered it via client-side JavaScript using an escape function that only replaced the first angle bracket, allowing an attacker to inject a script that executed when the comment was viewed.

infosecwriteups.com

Published on infosecwriteups.com

Stored DOM XSS is a form of cross-site scripting where malicious scripts are persistently stored on the server, commonly in a database or similar backend — and are later inserted into a page’s Document Object Model (DOM) by client-side JavaScript without proper sanitization.

Bash Overflow, on infosecwriteups.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

Impact

An attacker could steal session cookies or tokens and use DOM control to launch more advanced client-side attacks.

What the attacker needed

A blog with comment submission; victim views the comment

How it was found

  1. Open the lab and navigate to a blog article with a comment form.
  2. Submit a simple script tag as a comment and observe that it is HTML-encoded.
  3. Inspect the client-side JavaScript in Burp Suite and find the escapeHTML function.
  4. Craft a comment that bypasses the weak encoding.
  5. Reload the article and the payload 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.

When you leave a comment on a website, the site usually saves it and shows it to others. If the site does not clean the comment properly before displaying it, an attacker can include code that runs in other visitors' browsers. This is called cross-site scripting, and here the cleaning step was incomplete.

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.