Skip to content
XSS Disclosed report Beginner

Page title not escaped, XSS vector

The page title was not escaped when rendered, allowing an attacker to inject HTML and JavaScript. An attacker could execute arbitrary script in the context of the page, as demonstrated by an alert.

John Whitlock Follow

Originally disclosed on Mozilla

  • Fixed in 1 hour
  • Paid in 20 days
  • Disclosed after 1 hour
Text
What did you do?
================
1. Edit a page
2. Select "Edit Page Title and Properties" 
3. Change title to '</title><Img src=x onerror=alert(1)>'
4. Publish


What happened?
==============
The unescaped title is added to the page, and an alert is shown

What should have happened?
==========================
The title should have been escaped as '&lt;/title&gt;&lt;Img src=x onerror=alert(1)&gt;'

Is there anything else we should know?
======================================
First discovered by MDN user MuzammilAbbasKayani:

https://developer.mozilla.org/en-US/docs/Tools$revision/1145840

The original report as published on Mozilla's Bugzilla, by John Whitlock. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The target is the Mozilla developer platform, specifically the page editing feature on developer.mozilla.org. The researcher, John Whitlock, reported a stored cross-site scripting issue in the way a page title is rendered.

The reproduction steps are short and direct:

  1. Edit a page.
  2. Select "Edit Page Title and Properties".
  3. Change the title to the payload below.
  4. Publish.

The payload used as the new title was:

HTML
</title><Img src=x onerror=alert(1)>

After publishing, the unescaped title was added to the page and the browser executed the handler, showing an alert. In other words, the title value was written into the page markup without encoding, so the closing </title> tag ended the title element early and the following <Img> element was parsed as part of the document, with its onerror handler firing when the bogus image source failed to load.

The researcher states what should have happened: the title should have been escaped so that the angle brackets and the rest of the payload appear as text rather than markup:

HTML
&lt;/title&gt;&lt;Img src=x onerror=alert(1)&gt;

The report also credits the original discovery to an MDN user, MuzammilAbbasKayani, and links to the affected revision of the Tools documentation page. No bounty amount is given, and the report does not describe the fix that was applied.

Root cause

The likely root cause is output encoding applied to the wrong context, or not applied at all. A page title is not only shown in a heading; it is also placed inside the HTML <title> element in the document head. If the application inserts the stored title into that element without HTML-encoding it, any markup in the title becomes live markup. The payload works because </title> closes the element, after which the parser treats the remaining input as ordinary body content.

The report points at the rendering side, not at input validation: the title was accepted and stored, and the problem appeared when it was written back into the page.

Impact

The title is saved and rendered back into the page, so the report treats it as a stored cross-site scripting issue. An attacker able to edit a title could run script in the browser of anyone who views the affected page, in the origin of the documentation site, if the stored title is rendered to them. The report demonstrates this only with alert(1); it does not describe theft of sessions, account takeover or any other concrete exploitation.

How this kind of bug works

Cross-site scripting happens when untrusted data is placed into an HTML document without being encoded for the context it lands in. Browsers parse HTML with a state machine: inside a <title> element, the parser is in RCDATA state, where character references are decoded but tags are not, until it meets the literal end tag </title>. A value containing that sequence therefore breaks out of the element, and everything after it is parsed as normal markup, including event handler attributes such as onerror.

The same class of mistake appears wherever a single stored value is reused in several contexts: a heading, a <title>, a meta tag, an attribute, a JavaScript string, a JSON response. Each context needs its own encoding. HTML entity encoding is correct for element text and for the title element; attribute values need quoting plus encoding; JavaScript and CSS contexts need different treatment again. Defences that stop this bug class are context-aware output encoding, a restrictive Content Security Policy that blocks inline handlers, and, where rich text is genuinely required, server-side sanitisation with a well-maintained HTML sanitiser.

How to test for it

The title field is a good candidate because developers often encode the visible heading but forget the <title> element or a meta tag.

A practical method:

  1. Identify every field that is echoed back after saving, and note every location it appears in (browser tab title, page heading, breadcrumbs, meta tags, search results, notification emails).
  2. Submit a harmless marker first, such as a unique string, and confirm where it is reflected and whether it is stored.
  3. Submit a payload that closes the surrounding context. For a title element, a closing title tag followed by an element with an event handler is the classic probe; for attributes, break out of the quotes.
  4. Reload the page in a fresh session and check whether the handler fires or the markup is parsed as elements rather than text.
  5. View the raw response to see whether the characters were encoded or passed through verbatim.

A positive result is markup you supplied being parsed as markup: an element appears in the DOM inspector that you created, or a handler executes. Common false positives are payloads that are reflected but encoded (the angle brackets appear as entities in the source), payloads that only execute in your own browser because of a client-side preview, and self-XSS where the value is only rendered back to the person who entered it. Check whether a second account or an unauthenticated visitor sees the same execution; that is what turns a reflection into a stored issue.

How it is fixed

Apply HTML entity encoding to the title wherever it is written into HTML, including the <title> element and any meta tags. Use a templating engine that escapes by default and be explicit about contexts where auto-escaping does not apply. Add a Content Security Policy that disallows inline event handlers and inline scripts, which limits the damage of any encoding mistake that slips through. Where titles must support formatting, sanitise on the server with an allowlist-based sanitiser rather than relying on client-side filtering. Regression tests should assert that a title containing angle brackets is rendered as text.

Hunting notes

This bug class hides in secondary rendering paths: the browser tab title, Open Graph and Twitter meta tags, RSS feeds, sitemaps, PDF exports, admin panels that display user content, and email templates. Anywhere a stored value is reused outside the main page body is worth checking, because the main body is usually the path developers test.

Recon signals include editable content features, custom titles and descriptions, and any application that lets users set metadata about their own objects. Watching how a value is rendered in the page source, not just visually, is the quickest way to spot missing encoding.

Keep the payload minimal, state clearly which context is broken, and describe the fix in terms of encoding for that context.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

This report is about developer.mozilla.org, Mozilla's documentation site for web developers. The site lets people edit documentation pages, and one of the things you can change is the page title. A title is the short name of the page: it appears as the heading on the page and also in the browser tab.

John Whitlock reported that a page title was not handled safely. When a title containing HTML code was saved, the site put that code into the page as if it were part of the page itself, and the browser ran it.

The steps to reproduce it were short:

  1. Edit a page.
  2. Select "Edit Page Title and Properties".
  3. Change the title to the text below.
  4. Publish.

The title used was:

HTML
</title><Img src=x onerror=alert(1)>

To understand why this matters, you need to know a little about how web pages are built. A web page is a text document written in HTML, a language made of tags. Tags are the instructions in angle brackets, like <title>, that tell the browser what each piece of content is. The browser reads the document from top to bottom and builds the page as it goes. Some tags come in pairs: an opening tag such as <title> and a closing tag such as </title>, with the content in between.

The title text above is designed to break out of that pair. The first part, </title>, is a closing tag. When the browser reaches it, it thinks the title section has ended. Everything after it is then treated as ordinary page content rather than as title text. The second part, <Img src=x onerror=alert(1)>, is an image tag. src=x tells the browser to load an image from a location called x, which does not exist, so the image fails to load. onerror=alert(1) is an instruction that says: when the image fails, run this small piece of JavaScript, the programming language browsers use to make pages interactive. alert(1) makes a pop-up box appear with the number 1 in it.

So the browser closed the title early, tried to load a broken image, failed, and ran the pop-up code. The researcher saw the alert appear after publishing. The site placed the unescaped title into the page without converting the angle brackets into harmless text.

The report says what should have happened instead: the title should have been escaped, meaning the special characters should be converted so the browser shows them as plain text rather than treating them as instructions. The escaped version would look like this:

HTML
&lt;/title&gt;&lt;Img src=x onerror=alert(1)&gt;

Here &lt; is the written form of a less-than sign and &gt; is the written form of a greater-than sign. A browser displays these as < and > on screen but does not treat them as the start or end of a tag. The visitor would simply see the odd-looking text as part of the title, and nothing would run.

The report credits the original discovery to an MDN user, MuzammilAbbasKayani, and links to the affected revision of the Tools documentation page. It does not give a bounty amount, and it does not describe how the problem was fixed.

Why does this matter beyond a pop-up? The title is saved and rendered back into the page when it is opened. A pop-up is a harmless demonstration, but the same trick could run any JavaScript the author chose, in the browser of anyone who views the page, on the documentation site's own address. The report demonstrates only the pop-up and does not describe theft of accounts or other concrete harm.

In general, how this kind of bug works

This is called cross-site scripting, often shortened to XSS. The everyday comparison is a notice board where anyone can pin a note. The board trusted the note's content. A website that inserts user text into its pages without encoding is doing the same thing: it trusts the text to be text, when it might be instructions.

The specific flavour here is stored cross-site scripting. The dangerous text is saved on the server, not just shown back once, so it reaches other people later. The alternative, reflected XSS, appears only in a single response, for example when a search term is echoed back in the results page.

The technical reason the payload works is about how browsers read HTML. Inside a <title> element the browser is in a special mode where it treats almost everything as text, until it meets the exact closing tag </title>. A value containing that sequence ends the element, and whatever follows is read as normal page markup, including event handlers such as onerror. The same mistake appears wherever one saved value is reused in several places: a heading, the browser tab title, a meta tag, an attribute, a script. Each place needs its own kind of encoding, because the rules for what is dangerous differ.

The defences are straightforward in principle. Encode output for the context it lands in, so angle brackets become entities in HTML text. Use a templating system that escapes by default. Add a Content Security Policy, a set of rules the server sends telling the browser which scripts may run, which can block inline handlers like onerror. If titles genuinely need formatting, clean them on the server with an allowlist-based sanitiser, a tool that permits only known-safe markup and removes the rest.

If you want to look for this kind of bug yourself, start with fields that are saved and then shown in more than one place: page titles, display names, project names, file names, category labels. A practical method:

  1. Find every field that comes back after saving, and note every place it appears: browser tab, heading, breadcrumbs, meta tags, search results, emails.
  2. Save a harmless unique word first and confirm where it shows up and that it is stored.
  3. Try a value that closes the surrounding context, such as a closing title tag followed by an element with an event handler.
  4. Reload in a fresh session and check whether the handler runs or the markup is treated as elements rather than text.
  5. View the raw page source to see whether the characters were encoded or passed through unchanged.

A real finding is markup you supplied being treated as markup. Watch for false positives: text that is reflected but encoded (you see entities in the source), code that only runs in your own browser because of a preview feature, and self-XSS, where the value is only shown back to the person who typed it. The strongest evidence is a second account, or a logged-out visitor, seeing the same execution.

Glossary

  • HTML: the language web pages are written in, made of tags in angle brackets that describe content.
  • Tag: an instruction in HTML, such as <title> or <Img>, usually in a pair with a closing form like </title>.
  • Element: a complete piece of HTML, from its opening tag to its closing tag, plus the content between them.
  • Attribute: extra information inside a tag, such as src=x or onerror=....
  • JavaScript: the programming language browsers run to make pages interactive.
  • Event handler: an attribute that tells the browser to run code when something happens, such as an image failing to load.
  • Payload: the text an attacker submits to try to trigger a bug.
  • Escaping (encoding): converting special characters into harmless written forms, such as &lt; for <, so they display as text rather than acting as instructions.
  • Cross-site scripting (XSS): a bug where untrusted text is placed into a page without proper encoding, so it can run as code.
  • Stored XSS: XSS where the dangerous text is saved on the server and shown to later visitors.
  • Reflected XSS: XSS where the dangerous text appears only in a single response, such as a search results page.
  • Self-XSS: a case where the text is only shown back to the person who entered it, so no one else is affected.
  • Content Security Policy: rules sent by a server telling the browser which scripts are allowed to run.
  • Sanitiser: a tool that removes unsafe markup from user content, keeping only what is on an allowlist.
  • False positive: a test result that looks like a bug but is not one.

More from Mozilla

View all

The newest disclosed reports for this program.

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.