<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>159241</bug_id>
          <alias>CVE-2016-4734</alias>
          <creation_ts>2016-06-28 17:50:45 -0700</creation_ts>
          <short_desc>Possible Info Leak in TypedArray.indexOf/lastIndexOf</short_desc>
          <delta_ts>2017-10-11 10:25:31 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>159400</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Natalie Silvanovich">natashenka</reporter>
          <assigned_to name="Keith Miller">keith_miller</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1206247</commentid>
    <comment_count>0</comment_count>
      <attachid>282308</attachid>
    <who name="Natalie Silvanovich">natashenka</who>
    <bug_when>2016-06-28 17:50:45 -0700</bug_when>
    <thetext>Created attachment 282308
Crashing sample

There is a possible info leak in TypedArray.indexOf. In JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h, the function genericTypedArrayViewProtoFuncIndexOf has the following code:

    JSValue valueToFind = exec-&gt;argument(0);
    unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);

    typename ViewClass::ElementType* array = thisObject-&gt;typedVector();
    typename ViewClass::ElementType target = ViewClass::toAdaptorNativeFromValue(exec, valueToFind);
    if (exec-&gt;hadException())
        return JSValue::encode(jsUndefined());

    for (; index &lt; length; ++index) {
        if (array[index] == target)
            return JSValue::encode(jsNumber(index));
    }

There are two places that an attacker can call into script and neuter the array and cause problems. The first is at the argumentClampedIndexFromStartOrEnd, in which case array will be 0, and an absolute pointer specified by index can be compared against value. It&apos;s also possible to use this issue as a read-only use-after-free by setting the first parameter to an object with valueOf defined. Since this value is converted after the array pointer is set, the array will be searched after it is freed.

I&apos;m not sure if searching an array bytewise for every value between 0 and 255 is a practical attack, so there is no deadline on this issue unless we figure out how to exploit it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1210472</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2016-07-13 09:13:46 -0700</bug_when>
    <thetext>&lt;rdar://problem/27324561&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1211142</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-07-14 14:24:35 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; The first is at the argumentClampedIndexFromStartOrEnd, in which case array will be 0, and an
&gt; absolute pointer specified by index can be compared against value. 

This no longer an issue because r202982: &lt;http://trac.webkit.org/changeset/202982&gt; added a neuter check immediately after the call to argumentClampedIndexFromStartOrEnd().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1211149</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-07-14 14:38:57 -0700</bug_when>
    <thetext>Brent, it&apos;s not fixed yet.  There&apos;s a second issue ...

(In reply to comment #0)
&gt; It&apos;s also possible to use this issue as a read-only use-after-free by setting the
&gt; first parameter to an object with valueOf defined. Since this value is
&gt; converted after the array pointer is set, the array will be searched after
&gt; it is freed.

Here, I think Natalie is referring to this line in the code:
    typename ViewClass::ElementType target = ViewClass::toAdaptorNativeFromValue(exec, valueToFind);

Keith already has this baking in a fix he&apos;s implementing.

So, I&apos;ll send this bug over to Keith.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1212024</commentid>
    <comment_count>4</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2016-07-18 11:17:15 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 159400 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>282308</attachid>
            <date>2016-06-28 17:50:45 -0700</date>
            <delta_ts>2016-06-28 17:50:45 -0700</delta_ts>
            <desc>Crashing sample</desc>
            <filename>indexOf.html</filename>
            <type>text/html</type>
            <size>504</size>
            <attacher name="Natalie Silvanovich">natashenka</attacher>
            
              <data encoding="base64">PGh0bWw+Cjxib2R5Pgo8c2NyaXB0PgoKZnVuY3Rpb24gZigpewogICB0cnl7CiAgIGFsZXJ0KCJ0
Iik7CiAgIHBvc3RNZXNzYWdlKCJ0ZXN0IiwgImh0dHA6Ly8xMjcuMC4wLjEiLCBbcV0pCiAgIGFs
ZXJ0KGEuYnl0ZUxlbmd0aCk7CiAgIGFsZXJ0KHEuYnl0ZUxlbmd0aCk7CiAgfSBjYXRjaChlKXsK
ICAgICBhbGVydChlLm1lc3NhZ2UpOwogICBhbGVydChhLmJ5dGVMZW5ndGgpCiAgIGFsZXJ0KHEu
Ynl0ZUxlbmd0aCk7CiAgfQogICByZXR1cm4gMHgxMjM0NTY3ODsKfQoKYWxlcnQoRGF0ZSk7Cgp2
YXIgcSA9IG5ldyBBcnJheUJ1ZmZlcigweDdmZmZmZmZmKTsKdmFyIG8gPSB7dmFsdWVPZiA6IGZ9
CnZhciBhID0gbmV3IFVpbnQ4QXJyYXkocSk7CgogIC8vIGFsZXJ0KHEuYnl0ZUxlbmd0aCk7CnZh
ciB0ID0gW107Cgp0cnl7CiAgICBhLmluZGV4T2YoMHgxMiwgbyk7Cn0gY2F0Y2goZSl7CgogICAg
YWxlcnQoZS5tZXNzYWdlKTsKCn0KCjwvc2NyaXB0Pgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>