Skip to content
XSS Write-up Beginner

How I Found a Stored XSS Vulnerability While Testing for Self-XSS

The application rendered HTML from user-controlled content, including PDF filenames and article editor input, without sanitisation. An attacker could store a JavaScript payload in an article that executes when another user views it, potentially performing actions with the victim's session.

Sudheer Follow

Published on medium.com

Most people say finding an XSS vulnerability is difficult. Blind XSS is something you can check in many input fields, but finding a working Stored XSS vulnerability is different.

Sudheer, 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 failed to sanitise or encode user-controlled HTML before storing and rendering it, allowing dangerous elements and event handlers to execute.

Impact

An attacker could store malicious JavaScript in an article that executes when other users view it, potentially performing actions with the victim's session, modifying content, redirecting users, or targeting privileged users.

What the attacker needed

Ability to create and publish an article; victim views the affected article

The fix

The application should sanitise untrusted HTML before storing or rendering it, using a well-tested HTML sanitizer with a strict allowlist, and encode user-controlled content based on context; a strong CSP can add defence in depth.

How it was found

  1. Upload a PDF with a filename containing HTML markup, modifying the request via the browser console.
  2. Observe that the application renders the HTML in the filename instead of displaying it as text.
  3. Create and publish an article, then paste HTML containing an image with an invalid source and an onerror handler into the editor.
  4. Save the article and observe the JavaScript popup, confirming execution.
  5. Open the same article in a different browser to confirm the payload was stored server-side and executes for other sessions.

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 shows content that a user typed, it must treat that content as plain text, not as code. Here, the site treated the content as HTML and JavaScript, so a script hidden in an article ran in the browser of anyone who opened it. That lets an attacker act as the victim on the site.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Sudheer

View all

1 more disclosed report, best first.

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.