<?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>51097</bug_id>
          
          <creation_ts>2010-12-15 00:09:47 -0800</creation_ts>
          <short_desc>Primordial privilege escalation from bad this-coercion</short_desc>
          <delta_ts>2011-07-20 19:18:52 -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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>64250</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Mark S. Miller">erights</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>barraclough</cc>
    
    <cc>erights</cc>
    
    <cc>ggaren</cc>
    
    <cc>jwalden+bwo</cc>
    
    <cc>oliver</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>322527</commentid>
    <comment_count>0</comment_count>
    <who name="Mark S. Miller">erights</who>
    <bug_when>2010-12-15 00:09:47 -0800</bug_when>
    <thetext>To avoid privilege escalation bugs by global object leakage, ES5 repaired Ch15 to coerce the this-bindings of its methods by &quot;ToObject&quot;. Thus, primitive values wrap but null and undefined throw an exception instead. For example, 15.4.4.10 Array.prototype.slice step 1 says:

    1. Let O be the result of calling ToObject passing the this value as the argument.

However, on WebKit nightly (Safari Version 5.0.1 (5533.17.8, r73886))

  window[0] = &apos;a&apos;;
  window[1] = &apos;b&apos;;
  window[2] = &apos;c&apos;;
  window.length = 3;
  [].slice.call(null, 0); // prints a,b,c

showing that slice still leaks access to the global object.

Even though this is a security bug, I have entered this as a WebKit bug, not a security bug, because no released Safari yet implements ES5, so there is time to fix this before it causes harm.

See also https://bugzilla.mozilla.org/show_bug.cgi?id=619283</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>337723</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-01-20 16:57:41 -0800</bug_when>
    <thetext>&lt;rdar://problem/8895966&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>391517</commentid>
    <comment_count>2</comment_count>
      <attachid>90865</attachid>
    <who name="Mark S. Miller">erights</who>
    <bug_when>2011-04-23 19:06:08 -0700</bug_when>
    <thetext>Created attachment 90865
&apos;valueOf()&apos; in a script tag still does bad this coercion

The attachment should alert &apos;ok&apos; and does so correctly on FF4. On Safari Version 5.0.4 (5533.20.27, r84622) it alerts &apos;bad value: [object DOMWindow]&apos; instead. Should this case be reported as part of this bug 51097, or should I file a distinct bug?

See https://bugzilla.mozilla.org/show_bug.cgi?id=652375</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>417338</commentid>
    <comment_count>3</comment_count>
    <who name="Mark S. Miller">erights</who>
    <bug_when>2011-06-08 10:40:59 -0700</bug_when>
    <thetext>Should this be merged with https://bugs.webkit.org/show_bug.cgi?id=58338 ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>440191</commentid>
    <comment_count>4</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-07-20 19:18:52 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 64250 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>90865</attachid>
            <date>2011-04-23 19:06:08 -0700</date>
            <delta_ts>2011-04-23 19:06:08 -0700</delta_ts>
            <desc>&apos;valueOf()&apos; in a script tag still does bad this coercion</desc>
            <filename>implicit-this.html</filename>
            <type>text/html</type>
            <size>205</size>
            <attacher name="Mark S. Miller">erights</attacher>
            
              <data encoding="base64">PCFkb2N0eXBlIGh0bWw+Cjxib2R5PjxzY3JpcHQ+CiB0cnkgeyAKICAgYWxlcnQoJ2JhZCB2YWx1
ZTogJyArIHZhbHVlT2YoKSk7IAogfSBjYXRjaCAoZXJyKSB7CiAgIGlmIChlcnIgaW5zdGFuY2Vv
ZiBUeXBlRXJyb3IpIHsgYWxlcnQoJ29rJyk7IAogICB9IGVsc2UgeyBhbGVydCgnYmFkIHRocm93
OiAnICsgZXJyKTsgfQogfQo8L3NjcmlwdD48L2JvZHk+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>