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

Use after free in XML (CVE-2026-9947)

A double-free vulnerability in libxslt occurs when a whitespace-only text node inside an xsl:attribute with xml:space="preserve" bypasses dictionary interning and is later aliased into the result tree, leading to the same heap buffer being freed twice. On Android, where MiraclePtr is disabled, this could allow overlapping allocations and potentially remote code execution in the renderer.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 41 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 go/chrome-ai-generated-security-bugs-faq for more information.

Overview: A potential double-free vulnerability exists in libxslt when handling whitespace-only text nodes within xsl:attribute elements that have xml:space="preserve" set. The text content bypasses dictionary interning but is later fast-copied via pointer aliasing, causing the same heap buffer to be freed twice during cleanup. On standard Android, where MiraclePtr is disabled for the renderer, this corrupts the PartitionAlloc thread cache, potentially leading to overlapping allocations and renderer Remote Code Execution.

Affected files:

  • third_party/libxslt/src/libxslt/attributes.c
  • third_party/libxslt/src/libxslt/xslt.c
  • third_party/libxml/src/tree.c
  • third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc

Estimated timestamp from git blame: 2015-09-16

Summary

A potential double-free vulnerability has been identified in the XSLT processing logic used by Chromium. The issue occurs due to an assumption mismatch in libxslt regarding dictionary interning. When a whitespace-only text node inside an xsl:attribute element preserves space, its content is allocated on the heap without being added to the parser dictionary. However, during transformation, the attribute logic assumes the content is dictionary-backed and aliases the raw pointer directly into the result tree. When Blink cleans up the result document and the stylesheet, the exact same heap pointer is passed to xmlFree twice.

While MiraclePtr mitigates this issue into a safe crash on Desktop platforms, standard Android builds disable MiraclePtr for the renderer process, allowing this to be leveraged for overlapping memory allocations and Remote Code Execution.

Root Cause Analysis

The vulnerability traces through three main phases:

1. Allocation and Parsing (third_party/libxml/src/SAX2.c) When libxml2 parses an XSLT document, the xmlSAX2TextNode callback attempts to intern text into the document's dictionary. For whitespace-only strings ("blank" nodes), it checks if len < 60. If an attacker provides 60 or more whitespace characters, this optimization is bypassed, and the string is allocated on the heap via xmlStrndup.

2. Stylesheet Preprocessing (third_party/libxslt/src/libxslt/xslt.c) During xsltPreprocessStylesheet, the engine processes the stylesheet tree. At line 3613, it encounters the whitespace text node:

C
} else if (cur->type == XML_TEXT_NODE) {
    if (IS_BLANK_NODE(cur)) {
        if (xmlNodeGetSpacePreserve(cur->parent) != 1) {
            deleteNode = cur;
        }
    } else if ((cur->content != NULL) && (internalize) && (!xmlDictOwns(style->dict, cur->content))) {
        // ... intern the string ...
    }

Because the node contains only whitespace (IS_BLANK_NODE is true) and the attacker explicitly set xml:space="preserve" on the parent xsl:attribute, the node is kept. Crucially, because it entered the if (IS_BLANK_NODE) branch, it bypasses the else if branch responsible for interning heap-allocated strings into the dictionary. The node retains its raw heap pointer.

3. Attribute Generation (third_party/libxslt/src/libxslt/attributes.c) During the transformation, xsltAttribute evaluates the attribute's children to attach them to the result tree. At line 1037:

C
if (ctxt->internalized && (ctxt->insert->doc != NULL) && (ctxt->insert->doc->dict == ctxt->dict)) {
    copyTxt = xmlNewText(NULL);
    copyTxt->content = inst->children->content; // Direct pointer aliasing

Because ctxt->internalized is true (inherited from the stylesheet initialization), libxslt assumes the string is safely interned in the dictionary and performs a direct pointer alias instead of a deep copy. The result tree now contains a node pointing to the exact same heap allocation as the stylesheet tree.

Double Free Trigger

When the transformation completes, XSLTProcessor::TransformToString in Blink performs cleanup:

  1. It calls xmlFreeDoc(result_doc). The DICT_FREE macro checks if the pointer is owned by the dictionary (it is not) and calls xmlFree, returning the chunk to PartitionAlloc's thread cache.
  2. Immediately after, it calls xsltFreeStylesheet(sheet). This traverses the stylesheet tree, finds the original text node, and calls xmlFree on the exact same pointer again, triggering a synchronous double free.

Exploitability and Platform Impact

  • Desktop/ChromeOS: MiraclePtr (BackupRefPtr) is enabled for the renderer process. The second free attempts to release the chunk, but ReleaseFromAllocator detects that kMemoryHeldByAllocatorBit is already cleared. This correctly triggers a deterministic PA_IMMEDIATE_CRASH(), resulting only in a safe Denial of Service.
  • Standard Android: MiraclePtr is explicitly disabled for the renderer process (BackupRefPtrEnabledProcesses::kNonRenderer in partition_alloc_features.cc). Consequently, the double-free check is bypassed. PartitionAlloc's ThreadCache::PutInBucket pushes the same pointer onto the freelist twice. This encodes the next pointer to point to itself (entry->next = entry). Because the shadow entry remains perfectly consistent with this corrupted next pointer, standard release builds will not crash during reallocation.

An attacker can trigger this vulnerability and subsequently request allocations of the same size class via Javascript. The corrupted freelist cycle will cause GetFromCache to repeatedly return the same memory address, granting the attacker overlapping objects. This is a classic and highly reliable primitive for achieving Remote Code Execution within the sandboxed Android renderer process.

Potential Reproduction Steps

(Note: These are theoretical steps based on code analysis; our tooling agent cannot execute code to verify the PoC.)

HTML
<script>
// 1. Create a stylesheet with >60 spaces inside an xsl:attribute preserving space.
var xsl = 
  "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" +
  "<xsl:template match=\"/\"><r><xsl:for-each select=\"//*\">" +
  "<e><xsl:attribute name=\"a\" xml:space=\"preserve\">" + " ".repeat(64) + "</xsl:attribute></e>" +
  "</xsl:for-each></r></xsl:template></xsl:stylesheet>";

var p = new DOMParser();
var proc = new XSLTProcessor();
// 2. Import stylesheet (parses and skips interning)
proc.importStylesheet(p.parseFromString(xsl, "text/xml"));
// 3. Transform (aliases pointer, then double-frees during Blink cleanup)
proc.transformToDocument(p.parseFromString("<r><a/><b/></r>", "text/xml"));
</script>

Proposed Fix

The mismatch between preprocessing and attribute generation must be resolved in libxslt. One potential fix in third_party/libxslt/src/libxslt/attributes.c is to verify dictionary ownership before taking the fast path:

C
if (ctxt->internalized &&
    (ctxt->insert->doc != NULL) &&
    (ctxt->insert->doc->dict == ctxt->dict) &&
    xmlDictOwns(ctxt->dict, inst->children->content)) // ADD THIS CHECK
{
    copyTxt = xmlNewText(NULL);
    copyTxt->content = inst->children->content;
    // ...
}

Alternatively, xsltPreprocessStylesheet could be updated to ensure that nodes bypassing the deleteNode logic due to xml:space="preserve" are still correctly interned into the dictionary if their content is currently heap-allocated.

Evaluated with Chrome root at commit: c0eb5541aebfa4ea08806eaf6e94bcc69f87ab2f


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. 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 a mismatch in libxslt: whitespace-only text nodes that bypass dictionary interning are later assumed to be dictionary-backed and aliased directly, causing a double free.

Impact

On standard Android, where MiraclePtr is disabled, this could lead to overlapping allocations and potentially remote code execution in the renderer; on Desktop/ChromeOS, MiraclePtr mitigates it to a safe crash (denial of service).

What the attacker needed

Victim visits a malicious page; Android renderer without MiraclePtr

The fix

The fix should add a check to verify dictionary ownership before taking the fast path in attributes.c, or ensure that nodes bypassing deletion due to xml:space="preserve" are still interned.

How it was found

  1. Create an XSLT stylesheet with an xsl:attribute containing more than 60 whitespace characters and xml:space="preserve".
  2. Import the stylesheet using XSLTProcessor.importStylesheet, which parses it and skips interning.
  3. Call transformToDocument to trigger the transformation, which aliases the pointer and then double-frees during cleanup.

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.

This report describes a memory bug in a library used by Chrome to process XML stylesheets. When a specially crafted stylesheet is processed, the same piece of memory is freed twice, which can corrupt memory and, on Android, might let an attacker run their own code inside the browser.

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.