Skip to content
Memory corruption Advisory Advanced CVE-2026-9897

Use after free in DOM (CVE-2026-9897)

A logic flaw in ProcessingInstruction::ProcessStylesheet means that changing a stylesheet's href from an external URL to a local anchor leaves a stale resource fetch registered. When that fetch later completes it triggers an XSL transformation that frees the libxml2 document while it is still being iterated, giving a heap use-after-free in the renderer that the author claims could lead to arbitrary read/write and RCE.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 months

Project Fortify, an experimental security project, has identified the following potential security issue.

Overview: A logic error in ProcessingInstruction::ProcessStylesheet allows a stale resource fetch to trigger an XSL transformation prematurely. This transformation frees the stylesheet document while it is still being iterated in XSLStyleSheet::LoadChildSheets, leading to a heap-use-after-free of libxml2 xmlNodes.

Affected files:

  • third_party/blink/renderer/core/dom/processing_instruction.cc
  • third_party/blink/renderer/core/xml/xsl_style_sheet_libxslt.cc
  • third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc
  • third_party/blink/renderer/core/xml/document_xslt.cc

Estimated timestamp from git blame: 2026-03-11

Summary

A potential heap-use-after-free (UAF) vulnerability exists in XSLStyleSheet::LoadChildSheets. The issue stems from a logic flaw in ProcessingInstruction::ProcessStylesheet where mutating a stylesheet's href from an external URL to a local anchor (e.g., #id) disarms the loading_ state guard but fails to clear the pending ResourceClient.

When the stale external fetch subsequently completes, it prematurely triggers an XSL transformation. This transformation frees the underlying libxml2 xmlDoc tree while LoadChildSheets is still iterating over its nodes. Because libxml2 objects are allocated via C malloc, they are not protected by MiraclePtr (BRP), making this a highly exploitable UAF in the renderer process.

Root Cause Analysis

In third_party/blink/renderer/core/dom/processing_instruction.cc, the ProcessStylesheet method handles two main branches: external and local.

  1. When an external href is processed, ClearResource() is called to detach previous clients, and loading_ is set to true.
  2. When a local href (starting with #) is processed, the code creates a local XSLStyleSheet, sets loading_ = false, and returns early without calling ClearResource().

If a script mutates the ProcessingInstruction data from an external URL to a local one while a fetch is in-flight, the loading_ guard is disarmed, but the stale ResourceClient remains registered. When the external fetch completes, NotifyFinished() is called. Because loading_ is now false, guards in SheetLoaded and ApplyXSLTransform are bypassed.

Potential Attack Scenario

Note: Our setup cannot currently verify this with a working exploit, but the code path appears highly reliable.

  1. Preparation: An attacker creates an HTML page embedding an XML document with a <?xml-stylesheet type="text/xsl" href="external.xsl"?> ProcessingInstruction (PI). The external.xsl server is configured to delay its response.
  2. External Fetch Initiated: ProcessingInstruction::ProcessStylesheet sets loading_ = true and initiates the asynchronous fetch for external.xsl.
  3. State Mutation: Before the fetch completes, the attacker uses synchronous JavaScript to mutate the PI's data attribute: pi.data = 'type="text/xsl" href="#local"';.
  4. Guard Disarmed: This triggers a second call to ProcessStylesheet("#local"). Because it's a local href, the function sets loading_ = false and returns early, bypassing the crucial ClearResource() call. The PI remains registered for the delayed external.xsl fetch.
  5. Fetch Completion: The external.xsl fetch finishes, triggering ProcessingInstruction::NotifyFinished. This creates a new XSLStyleSheet and calls ParseString(), which parses the XML via libxml2 into an xmlDocPtr.
  6. Child Iteration: ParseString calls LoadChildSheets(), which begins a while loop iterating over the xmlNodePtr children of the parsed document.
  7. Premature Transformation: The loop encounters an <xsl:import> element and synchronously fetches it. This bubbles up a CheckLoaded() call. Because loading_ was maliciously set to false in Step 4, ProcessingInstruction::IsLoading() returns false.
  8. UAF Trigger: Believing all stylesheets are fully loaded, DocumentXSLT::ApplyXSLTransform is called. It compiles the stylesheet, transferring ownership of the xmlDocPtr to libxslt, performs the transformation, and finally calls xsltFreeStylesheet, which entirely frees the xmlDocPtr tree via malloc.
  9. Synchronous Execution: The transformation result is committed via a frame navigation. The attacker's XSLT output contains a <script> tag, which executes synchronously, allowing the attacker to groom the heap and perfectly reclaim the newly freed xmlNodePtr chunks.
  10. The Crash/Exploit: The call stack unwinds back to the while loop in LoadChildSheets(). The code executes curr = curr->next; on the attacker-controlled, freed memory, leading to an arbitrary read/write primitive and RCE.

Suggested Fix

Ensure ClearResource() is always called in ProcessingInstruction::ProcessStylesheet before the local-href early return path. This guarantees that no stale fetches can trigger callbacks while the object is transitioning to an inconsistent state.

C++
void ProcessingInstruction::ProcessStylesheet(const String& href,
                                              const String& charset) {
  CHECK(IsXMLStylesheet());
  if (IsLocalSheet(href)) {
    ClearResource(); // <--- Add this line to clear any pending fetches
    local_href_ = href.substr(1);
    // ... rest of the local sheet handling
    return;
  }

  ClearResource();
  // ... external sheet handling
}

Evaluated with Chrome root at commit: a3f5fcb392f2902650ca2b71820e7e418787e18b


Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. Please feel free to reach out to me if you have concerns or feedback.

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

The local-href branch of ProcessStylesheet sets loading_ to false and returns early without calling ClearResource(), so a pending external fetch stays registered and its completion bypasses the loading guards.

Impact

The author states this could give an arbitrary read/write primitive and RCE in the renderer, but notes the setup could not verify it with a working exploit and that the code path only appears highly reliable.

What the attacker needed

Victim loads attacker page; attacker controls delayed XSL server; script runs before fetch completes

The fix

ClearResource() should always be called in ProcessStylesheet before the local-href early return so no stale fetch can fire callbacks during the transition.

How it was found

  1. Create an HTML page embedding an XML document with an xml-stylesheet processing instruction pointing at an external stylesheet whose server delays its response.
  2. The browser starts the asynchronous fetch and marks the processing instruction as loading.
  3. Before the fetch finishes, use synchronous JavaScript to change the processing instruction data so the href becomes a local anchor.
  4. The local branch runs, clears the loading flag but leaves the stale fetch registered.
  5. When the delayed external fetch completes, it parses the stylesheet and begins iterating its child nodes.
  6. An xsl:import inside the stylesheet causes a load check that now reports not loading, so the transformation runs, frees the document, and the loop then touches freed memory.

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 web page can point at a stylesheet file that lives elsewhere, and the browser fetches it in the background. If the page swaps that pointer to a local anchor while the download is still running, the browser forgets it is still waiting but keeps the download alive. When the download lands, the browser frees some memory it is still reading from, which is a use-after-free: reading memory that has already been handed back, which can crash the tab or, in theory, let an attacker run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.