New issue
Advanced search Search tips
Starred by 1 user
Status: Fixed
Owner:
Closed: Jul 2016
Cc:



Sign in to add a comment
WebKit: Memory Corruption in TypedArray.fill
Project Member Reported by natashenka@google.com, Jun 29 2016 Back to list
There is a bug in TypedArray.fill that can be used to write to an absolute pointer. 

In JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h, the function genericTypedArrayViewProtoFuncFill contains the following code:

    unsigned length = thisObject->length();
    unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 1, length);
    unsigned end = argumentClampedIndexFromStartOrEnd(exec, 2, length, length);

    if (end < begin)
        return JSValue::encode(exec->thisValue());

    if (!thisObject->setRangeToValue(exec, begin, end, valueToInsert))
        return JSValue::encode(jsUndefined());

argumentClampedIndexFromStartOrEnd will call valueOf on a parameter to the fill function, which can contain a function that neuters the this array, causing the pointer used by setRangeToValue to be null. However, the begin and end variables can be very large values, up to 0x7fffffff, which could be valid pointers on ARM and 32-bit platforms. This allows an absolute pointer in this range to be written to.

An HTML file demonstrating this issue is attached. This issue affects Safari Technology Preview and WebKit, but has not made it into production Safari yet (TypedArray.fill is not supported).

Note that there are three places that code can be excuted after the neutered check in this function, the begin and end parameter, and the value, which is converted in setRangeToValue. To fix this issue, a check needs to be performed after the value has been converted.

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.

 
fill.html
513 bytes View Download
Project Member Comment 1 by natashenka@google.com, Jun 29 2016
Project Member Comment 2 by natashenka@google.com, Jul 29 2016
Labels: -Restrict-View-Commit
Status: Fixed
Fixed in Nightly. Unrestricted.
Project Member Comment 3 by natashenka@google.com, Sep 20 2016
Labels: -Severity-High CVE-2016-4734 Severity-HIgh
Sign in to add a comment