Skip to content
XSS Advisory Advanced CVE-2026-14083

Insufficient validation of untrusted input in HTML (CVE-2026-14083)

The Sanitizer API's streaming setters (streamHTML, streamAppendHTML, streamPrependHTML) in safe mode fail to block operations targeting a script element, unlike the non-streaming setters. An attacker who can control the destination element could stream text into a live script element, which is then executed as JavaScript, leading to cross-site scripting.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 48 days

Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the Chrome Security team. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.

Overview: The Sanitizer API's safe-mode implementation potentially fails to prevent the mutation of script elements when using streaming setters like streamHTML. This allows attacker-controlled text to be inserted into a live <script> element and executed as JavaScript, leading to an XSS vulnerability. The issue arises from a missing validation check in the HTMLStream::Create function.

Affected files:

  • third_party/blink/renderer/core/html/html_stream.cc
  • third_party/blink/renderer/core/dom/container_node.cc
  • third_party/blink/renderer/core/sanitizer/sanitizer_api.cc
  • third_party/blink/renderer/core/html/parser/html_construction_site.cc

Estimated timestamp from git blame: 2026-03-19

Summary

A potential security vulnerability has been identified in the experimental Sanitizer API's safe-mode implementation. While non-streaming HTML setters (such as setHTML and appendHTML) correctly validate and block operations targeting <script> or <svg:script> elements in safe-mode, the streaming counterparts (streamHTML, streamAppendHTML, and streamPrependHTML) omit this critical check. This oversight allows an attacker to achieve Cross-Site Scripting (XSS) by streaming content into a live script element.

Root Cause Analysis

The Sanitizer API's safe-mode contract is designed to ensure that calling a safe setter on a <script> target is a no-op. This is enforced via SanitizerAPI::AllowMutatingRootElement in third_party/blink/renderer/core/sanitizer/sanitizer_api.cc.

Standard safe setters correctly funnel through ParseHTMLFragment in third_party/blink/renderer/core/html/parser/fragment_parser.cc, which applies this guard. However, the WritableStream safe setters (implemented in third_party/blink/renderer/core/dom/container_node.cc) instead use HTMLStream::Create, which currently fails to call AllowMutatingRootElement or perform an equivalent validation on the target element.

In third_party/blink/renderer/core/html/html_stream.cc at HTMLStream::Create (line 134):

C++
if (!target->IsElementNode() && !target->IsShadowRoot()) {
  exception_state.ThrowDOMException(DOMExceptionCode::kHierarchyRequestError,
                                    "Cannot stream before/after a node that "
                                    "is not an element or shadow root");
  return nullptr;
}
// Missing SanitizerAPI::AllowMutatingRootElement(sanitizer_mode, target) check here.

Potential Attack Scenario

  1. An application uses the Sanitizer API with streaming setters (e.g., element.streamAppendHTML()). Note: These features are currently experimental and require --enable-experimental-web-platform-features.
  2. An attacker influences the application logic or uses DOM clobbering to ensure the target for the stream is a <script> element.
  3. The application opens a stream to the script element using the safe-mode setter.
  4. The attacker writes a payload to the stream (e.g., alert(document.domain)).
  5. Because the target is a script tag, the HTML parser enters kPLAINTEXTState, treating all input as literal text.
  6. The StreamingSanitizer allows text nodes in all modes.
  7. The payload is appended directly into the live <script> element in the DOM.
  8. This child insertion triggers HTMLScriptElement::ChildrenChanged, which executes the appended content as JavaScript.

Impact

This leads to Universal Cross-Site Scripting (UXSS) in any application utilizing the experimental Sanitizer API's streaming methods in a way that an attacker can control the destination element. This bypasses the API's fundamental security guarantee that safe-mode setters will not execute scripts.

Suggested Fix

In third_party/blink/renderer/core/html/html_stream.cc, update HTMLStream::Create to call SanitizerAPI::AllowMutatingRootElement(sanitizer_mode, target). If the check returns false, the function should return nullptr (and optionally throw a DOMException), mirroring the behavior of the non-streaming ParseHTMLFragment implementation.

Note: This analysis was performed using static code review; an active proof-of-concept has not been executed.

Evaluated with Chrome root at commit: b3153093eb3c78c3e88ccf562bcbc20437a04b0e


Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:

  • If you are familiar with the severity guidelines, you may adjust the severity.
  • If this is a false positive, and there's no work to be done, please close as WAI.
  • If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.

Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.

The original report as published on the Chromium issue tracker. 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

Likely the streaming code path in HTMLStream::Create does not call the same AllowMutatingRootElement guard that the non-streaming fragment parser uses, so safe-mode setters can mutate a script element.

Impact

This could lead to universal cross-site scripting in any application using the experimental streaming Sanitizer API where an attacker can control the destination element, bypassing the API's guarantee that safe-mode setters will not execute scripts; the analysis is from static review only and no proof of concept was run.

What the attacker needed

Experimental web platform features enabled; app uses streaming Sanitizer setters; attacker controls the stream target element

The fix

HTMLStream::Create should call SanitizerAPI::AllowMutatingRootElement and return null (optionally throwing a DOMException) when the check fails, matching the non-streaming parser.

How it was found

  1. An application uses the Sanitizer API with streaming setters, which are experimental and need a feature flag.
  2. An attacker influences the application logic or uses DOM clobbering so the stream target is a script element.
  3. The application opens a stream to the script element using the safe-mode setter.
  4. The attacker writes a payload to the stream.
  5. The HTML parser treats the input as plain text and the sanitizer allows text nodes.
  6. The payload is appended into the live script element, and the script's children-changed handler executes it.

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.

The Sanitizer API is meant to let developers insert HTML safely, blocking dangerous things like scripts. The non-streaming versions correctly refuse to touch a script element, but the newer streaming versions forgot that check. So if an attacker can make the stream target a script tag, the text they send gets run as code in the page.

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.