Bug 159231 (CVE-2016-4733)

Summary: Memory Corruption in TypedArray.copyWithin
Product: WebKit Reporter: Natalie Silvanovich <natashenka>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Major CC: bfulgham, fpizlo, ggaren, keith_miller, oliver, webkit-bug-importer
Priority: P2 Keywords: HasReduction, InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Sample file causing issue
none
Patch fpizlo: review+

Natalie Silvanovich
Reported 2016-06-28 15:05:00 PDT
Created attachment 282289 [details] Sample file causing issue There is a bug in TypedArray.copyWithin that can be used to write to an absolute pointer. In JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h, the function genericTypedArrayViewProtoFuncCopyWithin contains the following code: long length = thisObject->length(); long to = argumentClampedIndexFromStartOrEnd(exec, 0, length); long from = argumentClampedIndexFromStartOrEnd(exec, 1, length); long final = argumentClampedIndexFromStartOrEnd(exec, 2, length, length); if (final < from) return JSValue::encode(exec->thisValue()); long count = std::min(length - std::max(to, from), final - from); typename ViewClass::ElementType* array = thisObject->typedVector(); memmove(array + to, array + from, count * thisObject->elementSize); argumentClampedIndexFromStartOrEnd will call valueOf on a parameter to the copyWithin function, which can contain a function that neuters the this array, causing the variable "array" to be null. However, the "to" and "from" 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.copyWithin is not supported). 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. -- [Our ref: https://bugs.chromium.org/p/project-zero/issues/detail?id=862] Credit is to Natalie Silvanovich of Google Project Zero
Attachments
Sample file causing issue (479 bytes, text/html)
2016-06-28 15:05 PDT, Natalie Silvanovich
no flags
Patch (36.80 KB, patch)
2016-07-06 12:02 PDT, Keith Miller
fpizlo: review+
Radar WebKit Bug Importer
Comment 1 2016-06-28 17:15:39 PDT
Keith Miller
Comment 2 2016-07-06 12:02:56 PDT
Keith Miller
Comment 3 2016-07-08 09:28:16 PDT
Mark Lam
Comment 4 2016-07-13 11:40:15 PDT
*** Bug 159239 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.