Skip to content
XSS Write-up Intermediate

Breaking Stored XSS Through Filter Bypass

A file-upload content field appeared to sanitise script tags, but an iframe with a srcdoc attribute bypassed the filter and executed JavaScript, confirming stored XSS. An attacker could run arbitrary JavaScript in other users' or admins' browsers when they viewed the stored content.

medium.com

Published on medium.com

A web application field that accepted user content appeared to be sanitizing script tags, with initial payloads being removed and appearing empty. However, a bypass using an iframe with the srcdoc attribute allowed JavaScript execution in the browser, confirming a stored XSS vulnerability.

Abhishek Kumar, 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

Impact

Stored XSS could allow an attacker to run arbitrary JavaScript in the context of other users or admins visiting the affected page, potentially leading to session theft, actions on behalf of the user, fake UI for credential harvesting, or compromise of administrator sessions.

What the attacker needed

Authorized VAPT engagement; ability to submit content to file-upload endpoint; victim views stored content

The fix

The application should use context-aware output encoding and an allowlist for HTML when needed, rather than blacklisting, and add defence in depth with CSP and secure cookie attributes.

How it was found

  1. Submit content containing an iframe with a srcdoc attribute to the vulnerable input.
  2. View the page where stored content is rendered.
  3. Observe JavaScript execution inside the iframe when the page is loaded by a user.

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 application let users submit content that was later shown to other people, including administrators. It tried to block dangerous code by removing obvious script tags, but it missed a different way of embedding code inside an iframe attribute. Because the code was saved and shown to others, it could run in their browsers and let an attacker 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.