Stored XSS on reports.
A stored cross-site scripting flaw existed in the name field of custom network reports, so a script entered there ran when the report was viewed. An attacker could use this to steal data from anyone who opened the affected report.
- Triaged in 6 days
- Fixed in 35 days
- Paid in 11 days
- Disclosed after 2 months
Summary: Stored XSS can be submitted on reports, and anyone who will check the report the XSS will trigger.
Description: Stored XSS, also known as persistent XSS, is the more damaging than non-persistent XSS. It occurs when a malicious script is injected directly into a vulnerable web application.
Steps To Reproduce:
- Go to https://app.mopub.com/reports/custom/
- Click New network report.
- On the name, enter payload: "><img src=x onerror=alert(document.domain)>
- Click Run and save then XSS will trigger.
Demonstration of the vulnerability: PoC: ████
Tested on Firefox and chrome.
Impact
The attacker can steal data from whoever checks the report.
What the report shows
This is a stored cross-site scripting report against MoPub's custom reports feature at app.mopub.com. The researcher found that a report name is stored and later rendered, so a script placed in the name executes for anyone who checks the report.
The reproduction steps are short and direct:
- Go to
https://app.mopub.com/reports/custom/. - Click New network report.
- In the name field, enter the payload:
"><img src=x onerror=alert(document.domain)>
- Click Run and save, and the XSS triggers.
The payload begins with ">, then injects an img element whose src is invalid, so the onerror handler fires alert(document.domain). The researcher tested on Firefox and Chrome and confirmed the behaviour in both. A proof-of-concept recording was included in the report but is not reproduced here.
The report does not describe the fix that was applied.
Root cause
The likely cause is that the report name is persisted and then written into the page without context-aware output encoding. The payload begins by breaking out of a quoted value, which suggests the name may be placed inside an HTML attribute, but the report does not identify the exact sink. If the value were HTML-encoded on output, the quote would become " and the injected tag would be inert. The report itself does not identify the exact sink, so the attribute context is an inference from the payload shape.
Impact
As the report puts it, an attacker can steal data from whoever checks the report. Because the script runs in the session of the person viewing the report, it executes with their privileges. The report does not describe which data could be reached. The practical ceiling depends on who views reports and what their session can access.
How this kind of bug works
Stored XSS happens when user-controlled input is saved by the application and later rendered into a page without being encoded for the context it lands in. The browser cannot tell developer-written markup from injected markup, so any tag or event handler that survives into the response is parsed and executed.
The context matters. Inside an HTML attribute, a double quote ends the attribute and lets an attacker add new attributes or close the tag entirely. Inside a script block, a closing tag or a string break is the escape. Inside a URL attribute, a javascript: scheme may work. Correct output encoding is context-specific: HTML entity encoding for element text and quoted attributes, JavaScript encoding inside script blocks, and URL encoding for URL components. Input validation alone is not a reliable defence because the same string may be safe in one sink and dangerous in another.
Defences that stop this class are output encoding at the sink, a strict Content Security Policy that blocks inline script and event handlers, and framework templating that escapes by default. Server-side sanitisation with a well-maintained HTML sanitiser helps where rich text is genuinely required.
How to test for it
- Identify every place where input is saved and later displayed: names, titles, labels, descriptions, comments, saved filters, report and dashboard names.
- Submit a unique, harmless marker first (for example a distinctive string) and find where it is rendered. This tells you the sink and its context.
- Send a context-appropriate probe. For an attribute context, try breaking out with a quote and adding an event handler on an element with a failing source. For text context, try a simple tag. For script context, try breaking the string.
- Reload the page and view it as a different user or session to confirm the value is stored, not just reflected.
- A positive result is your probe executing in the browser, for example a dialog showing the document domain, or a request to a host you control.
Common false positives: the marker appears but is HTML-encoded, so the payload renders as text; the payload fires only in your own browser because of a client-side preview that is not persisted; a browser extension or developer tool alters the page; or the value is sanitised on save but your test used a payload that the sanitiser happened to allow in a context you did not check. Always confirm with a fresh session and, where possible, a second account.
How it is fixed
- Apply context-aware output encoding wherever stored values are rendered, so quotes, angle brackets and ampersands become entities in attribute and text contexts.
- Use templating engines that escape by default and avoid string concatenation into HTML.
- Where rich HTML must be stored, sanitise on input and output with an allowlist-based sanitiser.
- Deploy a Content Security Policy that disallows inline script and inline event handlers, as defence in depth.
- Set cookies with
HttpOnlywhere appropriate so session theft via script is harder.
Hunting notes
Stored XSS tends to hide in features that save user-supplied labels and later show them in administrative or shared views: report and dashboard names, saved searches, project titles, tags, and notification templates. These fields are often validated on the form but not on render, and the render may happen in a different part of the application than the input.
Recon signals worth following: any feature with a name or title field that appears in a list, table or header; values echoed into HTML attributes such as title, value or data-*; and multi-user views where one user's saved content is shown to another. Watch for places where the same value is rendered in more than one context, since one sink may be encoded and another not.
To make impact convincing, show execution in a realistic victim context, state which users would view the affected page, and describe what their session could reach. A clear, reproducible payload with a short recording and the exact steps is usually enough; avoid payloads that only prove reflection or that depend on your own browser state.
What happened, in plain words
One of its features let a user build a custom report: you give the report a name and save it so you can look at it again later. The report is then shown back inside a web page, and the XSS triggers for anyone who checks it.
The researcher found that the name you type for a report is saved and then placed into that page, and a script in the name runs. That means a name can contain not just words but pieces of web page code, and the browser will treat that code as part of the page and run it. This is called stored cross-site scripting: "stored" because the bad value is kept on the server, and "scripting" because the browser ends up running a script.
A useful comparison is a guest book at a hotel reception. If a guest writes their name and the hotel later prints the page exactly as written, a guest could write a sentence that looks like an instruction to the next reader. Everyone who reads the book afterwards follows that instruction. Here the "guest book" is the saved report and the "next reader" is whoever opens it.
The reproduction steps are short:
- Go to
https://app.mopub.com/reports/custom/. - Click New network report.
- In the name field, enter the payload:
"><img src=x onerror=alert(document.domain)>
- Click Run and save, and the XSS triggers.
Let us take the payload apart piece by piece, because each character has a job:
"closes a quoted value that the page had already opened around the report name, ending that value early.>closes the HTML tag that was still open, so whatever comes next is treated as a brand new piece of page markup rather than as part of the name.<img src=x onerror=...>adds an image element.src=xpoints at an address that does not exist, so the image fails to load.onerror=alert(document.domain)is an event handler: a piece of script the browser runs when the image fails. Because the image always fails, the script always runs.alert(document.domain)opens a pop-up showing the domain of the page, which is a harmless way to prove that code is executing.
Step 3 matters because it is the input that gets saved. Step 4 matters because saving the report is what causes the page to be built and shown again, and that is the moment the stored name is placed into the page and the browser runs it. The researcher tested on Firefox and Chrome and saw the behaviour in both. A recording of the proof of concept was included in the report but is not reproduced here.
The report does not describe the fix that was applied.
As the report puts it, the attacker can steal data from whoever checks the report. The script runs inside the viewer's own browser session, so it acts with that person's permissions. The report does not say which data could be reached.
In general, how this kind of bug works
A web page is text that your browser reads and turns into something you can see and click. Some of that text is content (the words) and some is markup (instructions about structure, like "this is a heading" or "this is an image"). The browser has no way to tell markup the developers wrote from markup that arrived inside a user's input. If user input reaches the page without being converted into harmless text, the browser obeys it.
That conversion is called output encoding. It means replacing characters that have special meaning in markup with safe stand-ins. A double quote becomes ", a less-than sign becomes <, and so on. The page then displays the characters you typed without ever treating them as instructions.
The place where the value finally lands is called the sink, and the context of the sink decides what encoding is needed. Inside a quoted HTML attribute, a double quote is the escape character, which is exactly what the payload above abuses. Inside a script block, a closing tag or a broken string is the escape. Inside a link address, a javascript: prefix may work. This is why a single generic filter is not enough: the same string can be harmless in one place and dangerous in another.
Several defences stop this class of bug:
- Encode output at the sink, for the context it lands in.
- Use a templating system that escapes by default instead of gluing strings together into HTML.
- Where rich formatting is genuinely needed, clean the HTML with an allowlist-based sanitiser.
- Add a Content Security Policy that forbids inline script and inline event handlers, as a second layer.
- Mark session cookies
HttpOnlywhere possible, so a script cannot read them.
If you want to look for this kind of bug yourself, a sensible order is:
- List every place where you type something that is saved and shown again: names, titles, labels, descriptions, comments, saved filters, report and dashboard names.
- Save a unique, harmless marker first, such as a distinctive word, and find where it appears. That tells you the sink and its context.
- Send a probe suited to that context. In an attribute, try closing the quote and adding an event handler on an element that fails to load. In plain text, try a simple tag. In a script block, try breaking the string.
- Reload, and view the page in a different session or as a different user, to confirm the value was stored rather than just echoed back once.
- Treat a pop-up showing the document domain, or a request to a host you control, as confirmation.
Watch out for false positives. The marker may appear but be encoded, so it shows as text. The payload may fire only in your own browser because a preview is not actually saved. A browser extension or developer tool may be altering the page. Or the value may be cleaned on save, and your payload only worked in a context you did not examine. Confirm with a fresh session and, where you can, a second account.
Glossary
- Stored XSS: a vulnerability where malicious input is saved by the application and later shown to users, causing their browsers to run it.
- Payload: the specific piece of input crafted to trigger a vulnerability.
- HTML: the markup language browsers use to structure a web page.
- Tag: a markup instruction such as
<img>, which tells the browser to place an element on the page. - Attribute: a setting inside a tag, such as
srcorvalue, usually written asname="value". - Event handler: script attached to an element that runs when something happens, such as an image failing to load.
- Output encoding: converting characters with special meaning into safe stand-ins before placing them in a page.
- Sink: the place in the page where a value is finally written.
- Context: the surroundings a value lands in (text, attribute, script, URL), which decides what encoding is needed.
- Sanitiser: a tool that removes dangerous parts from HTML while keeping an allowed subset.
- Content Security Policy: a set of rules a site sends to the browser saying which scripts are allowed to run.
- Session: the logged-in state a site keeps for you, usually tied to a cookie.
- Cookie: a small piece of data the browser stores for a site and sends back with requests.
- HttpOnly: a cookie setting that stops scripts on the page from reading that cookie.
- Proof of concept: a minimal demonstration that a vulnerability is real.
- False positive: a result that looks like a vulnerability but is not one.