<?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>67820</bug_id>
          
          <creation_ts>2011-09-08 17:19:42 -0700</creation_ts>
          <short_desc>Initialize ExceptionCode in Element::removeAttribute</short_desc>
          <delta_ts>2011-09-13 00:56:17 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Klein">adamk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>darin</cc>
    
    <cc>dglazkov</cc>
    
    <cc>eae</cc>
    
    <cc>inferno</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>464519</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-08 17:19:42 -0700</bug_when>
    <thetext>Initialize ignored ExceptionCode in DatasetDOMStringMap::deleteItem</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464520</commentid>
    <comment_count>1</comment_count>
      <attachid>106821</attachid>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-08 17:24:14 -0700</bug_when>
    <thetext>Created attachment 106821
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464648</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-09-08 22:26:45 -0700</bug_when>
    <thetext>This fix doesn&apos;t look right. It&apos;s the job of code that cares about exception code to initialize it - and if valgrind reports a conditional jump based on uninitialized variable, than this other code failed to do it.

Element::removeAttribute() should set ec to 0 before calling removeNamedItem() and checking whether that changed ec.

CC&apos;ing Darin just in case I got it wrong again...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464887</commentid>
    <comment_count>3</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-09 10:38:29 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; This fix doesn&apos;t look right. It&apos;s the job of code that cares about exception code to initialize it - and if valgrind reports a conditional jump based on uninitialized variable, than this other code failed to do it.
&gt; 
&gt; Element::removeAttribute() should set ec to 0 before calling removeNamedItem() and checking whether that changed ec.
&gt; 
&gt; CC&apos;ing Darin just in case I got it wrong again...

Good call, and in fact that&apos;s what the other overload of removeAttribute() does.  I&apos;ve updated the code, the ChangeLog, and the bug title.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464888</commentid>
    <comment_count>4</comment_count>
      <attachid>106887</attachid>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-09 10:39:18 -0700</bug_when>
    <thetext>Created attachment 106887
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464944</commentid>
    <comment_count>5</comment_count>
      <attachid>106887</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2011-09-09 11:36:12 -0700</bug_when>
    <thetext>Comment on attachment 106887
Patch

Clearing flags on attachment: 106887

Committed r94869: &lt;http://trac.webkit.org/changeset/94869&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>464945</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2011-09-09 11:36:16 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466124</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-09-12 21:46:11 -0700</bug_when>
    <thetext>What&apos;s the security aspect here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466129</commentid>
    <comment_count>8</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2011-09-12 21:55:52 -0700</bug_when>
    <thetext>Uninitialized reads are equivalent to use after frees bugs. If you don&apos;t initialize the value, it might have a initial attacker controlled value in there which can be used for exploitation. I havent got a chance to look into the possibility of exploitation given that ec is only used for exception code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466133</commentid>
    <comment_count>9</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2011-09-12 22:11:43 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; Uninitialized reads are equivalent to use after frees bugs. If you don&apos;t initialize the value, it might have a initial attacker controlled value in there which can be used for exploitation. I havent got a chance to look into the possibility of exploitation given that ec is only used for exception code.

I think this can be used for uninitialized read, since if the ec is not set as NOT_FOUND_ERR, then ec will have default uninitialized value which can be probably read in javascript with try, catch blocks and reading exception.code value. If you think this is not possible at all, please let me know and i will remove the security tags.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466142</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-09-12 22:47:36 -0700</bug_when>
    <thetext>&gt; ec is only used for exception code

Right, there are few arbitrary code execution opportunities even if there was a code path where uninitialized ec was used in a substantial way. This code path certainly doesn&apos;t count as substantial:

        if (ec == NOT_FOUND_ERR)
            ec = 0;

&gt; can be probably read in javascript with try, catch blocks

I don&apos;t know if exposing a single uninitialized local variable to a script can actually be used for anything malicious, but this cannot happen here anyway.  All functions that can raise a JavaScript exception initialize ec first thing in generated bindings code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466164</commentid>
    <comment_count>11</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2011-09-12 23:43:48 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; &gt; ec is only used for exception code
&gt; 
&gt; Right, there are few arbitrary code execution opportunities even if there was a code path where uninitialized ec was used in a substantial way. This code path certainly doesn&apos;t count as substantial:
&gt; 
&gt;         if (ec == NOT_FOUND_ERR)
&gt;             ec = 0;
&gt; 

I am not worried about this path since this one just does == check and changes ec value. I don&apos;t see how code execution can happen here. What i do see as attacker wanting to get the value of uninitialized ec through javascript. this uninitialized value might be holding some important info that the attacker didnt had access to, and now he or she does. e.g. cross-origin info.

&gt; &gt; can be probably read in javascript with try, catch blocks
&gt; 
&gt; I don&apos;t know if exposing a single uninitialized local variable to a script can actually be used for anything malicious, but this cannot happen here anyway.  All functions that can raise a JavaScript exception initialize ec first thing in generated bindings code.

I agree that most paths are sanitized here since generated bindings code will initialize ec. In this case, we atleast know this one path through v8 bindings, where ec was uninitialized, and which caused the valgrind report in http://code.google.com/p/chromium/issues/detail?id=76490. If you don&apos;t mind, we would like to retain security tags on this.

UninitCondition
Conditional jump or move depends on uninitialised value(s)
  WebCore::Element::removeAttribute(WTF::String const&amp;, int&amp;) (third_party/WebKit/Source/WebCore/dom/Element.cpp:1448)
  WebCore::DatasetDOMStringMap::deleteItem(WTF::String const&amp;, int&amp;) (third_party/WebKit/Source/WebCore/dom/DatasetDOMStringMap.cpp:189)
  WebCore::V8DOMStringMap::namedPropertyDeleter(v8::Local&lt;v8::String&gt;, v8::AccessorInfo const&amp;) (third_party/WebKit/Source/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp:76)
  v8::internal::JSObject::DeletePropertyWithInterceptor(v8::internal::String*) (v8/src/objects.cc:2525)
  0xBED0CE43 ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466168</commentid>
    <comment_count>12</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-09-13 00:01:12 -0700</bug_when>
    <thetext>Please have a look at DatasetDOMStringMap::deleteItem(). It&apos;s no surprise that ec is not initialized.

I do not care personally, but this is pretty clearly not a security bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>466177</commentid>
    <comment_count>13</comment_count>
    <who name="Abhishek Arya">inferno</who>
    <bug_when>2011-09-13 00:56:17 -0700</bug_when>
    <thetext>After debugging, i understand that my understanding was wrong here. I was confusing that this uninitialized dummy variable (with ec) was retrievable via javascript, but it is not. Only ec is retrievable, which will get set of zero if this uninitialized dummy == NOT_FOUND_ERR. ec=0 is a common case, so this is not useful value. Removing security tags and sorry for the noise.

void DatasetDOMStringMap::deleteItem(const String&amp; name, ExceptionCode&amp; ec)
{
    if (!isValidPropertyName(name)) {
        ec = SYNTAX_ERR;
        return;
    }

    ExceptionCode dummy;
    m_element-&gt;removeAttribute(convertPropertyNameToAttributeName(name), dummy);
}</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>106821</attachid>
            <date>2011-09-08 17:24:14 -0700</date>
            <delta_ts>2011-09-09 10:39:15 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-67820-20110908172413.patch</filename>
            <type>text/plain</type>
            <size>1518</size>
            <attacher name="Adam Klein">adamk</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogOTQ3NDgKZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwppbmRleCBlMTA1MmQwMjI3ZDE2YjU2
NTU5MmQ1ZDc1MzhiMjljNWNhYjM1MDlkLi4zMTk5ODkxYmE2MDgyNDliYjg0ZDFmMDQyNTY3OWU1
Yjk0ZmFhOGJhIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvU291
cmNlL1dlYkNvcmUvQ2hhbmdlTG9n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TVN0cmluZ01hcC5jcHAKaW5kZXggZTY4ZTlkOTU5MjFiMzg2NTA5
NjBhMDFhM2NkMTUyYjZlNGJlNzcxZi4uYzRmMGI3ZTRiN2MyYjE4ZDkwNTE2ZjZkNzA2NDc5ZmEw
Y2FhOGQyNCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvZG9tL0RhdGFzZXRET01TdHJpbmdN
YXAuY3BwCisrKyBiL1NvdXJjZS9XZWJDb3JlL2RvbS9EYXRhc2V0RE9NU3RyaW5nTWFwLmNwcApA
QCAtMTk5LDcgKzE5OSw3IEBAIHZvaWQgRGF0YXNldERPTVN0cmluZ01hcDo6ZGVsZXRlSXRlbShj
b25zdCBTdHJpbmcmIG5hbWUsIEV4Y2VwdGlvbkNvZGUmIGVjKQogICAgICAgICByZXR1cm47CiAg
ICAgfQogCi0gICAgRXhjZXB0aW9uQ29kZSBkdW1teTsKKyAgICBFeGNlcHRpb25Db2RlIGR1bW15
ID0gMDsKICAgICBtX2VsZW1lbnQtPnJlbW92ZUF0dHJpYnV0ZShjb252ZXJ0UHJvcGVydHlOYW1l
VG9BdHRyaWJ1dGVOYW1lKG5hbWUpLCBkdW1teSk7CiB9CiAK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>106887</attachid>
            <date>2011-09-09 10:39:18 -0700</date>
            <delta_ts>2011-09-09 11:36:11 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-67820-20110909103917.patch</filename>
            <type>text/plain</type>
            <size>1480</size>
            <attacher name="Adam Klein">adamk</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogOTQ3NDgKZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwppbmRleCBlMTA1MmQwMjI3ZDE2YjU2
NTU5MmQ1ZDc1MzhiMjljNWNhYjM1MDlkLi4xOGZ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