<?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>16073</bug_id>
          
          <creation_ts>2007-11-20 10:35:03 -0800</creation_ts>
          <short_desc>xss possible because of a bug in Document::setDomain</short_desc>
          <delta_ts>2007-11-26 17:53:10 -0800</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>PC</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Feng Qian">ian.eng.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ddkilzer</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61805</commentid>
    <comment_count>0</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-20 10:35:03 -0800</bug_when>
    <thetext>Document::setDomain updates securityOrigin to new domain even when new domain is not a suffix of the current domain. If frame A and B change their domains to an invalid third party domain, A and B are accessible to each other even when there are from different domain.

A layout test and fix is coming.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61814</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-11-20 12:14:17 -0800</bug_when>
    <thetext>&lt;rdar://problem/5609222&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61859</commentid>
    <comment_count>2</comment_count>
      <attachid>17421</attachid>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-20 16:10:21 -0800</bug_when>
    <thetext>Created attachment 17421
A patch with a test

A test case according to the format. Feel free to change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61864</commentid>
    <comment_count>3</comment_count>
      <attachid>17421</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-20 16:55:02 -0800</bug_when>
    <thetext>Comment on attachment 17421
A patch with a test

Assuming you tested the test case before and after the change, r=me.

It&apos;s not that important, but Document::setDomain is also in need of a little love to get rid of those nasty nested ifs.  Early return for the win.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61866</commentid>
    <comment_count>4</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-20 16:59:42 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 17421 [edit])
&gt; Assuming you tested the test case before and after the change, r=me.

Yes.

&gt; 
&gt; It&apos;s not that important, but Document::setDomain is also in need of a little
&gt; love to get rid of those nasty nested ifs.  Early return for the win.
&gt; 

Can we get rid of Document::m_domain and use m_securityOrigin.host() instead? Looks like it is not much useful.


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61876</commentid>
    <comment_count>5</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-20 19:04:50 -0800</bug_when>
    <thetext>Thanks, are you going to land the patch soon?

(In reply to comment #3)
&gt; (From update of attachment 17421 [edit])
&gt; Assuming you tested the test case before and after the change, r=me.
&gt; 
&gt; It&apos;s not that important, but Document::setDomain is also in need of a little
&gt; love to get rid of those nasty nested ifs.  Early return for the win.
&gt; </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61877</commentid>
    <comment_count>6</comment_count>
      <attachid>17421</attachid>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2007-11-20 20:12:59 -0800</bug_when>
    <thetext>Comment on attachment 17421
A patch with a test

Whoever lands this patch should split the ChangeLog entry and put it in WebCore/ChangeLog and LayoutTests/ChangeLog, instead of at the top level.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61953</commentid>
    <comment_count>7</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-21 16:03:12 -0800</bug_when>
    <thetext>The patch is over-restricted. It should allow set to the same domain. So it needs a fix before getting the length of domain names.

    // Both NS and IE specify that changing the domain is only allowed when
    // the new domain is a suffix of the old domain.

    // FIXME: We should add logging indicating why a domain was not allowed.

    // NOTE: If the new domain is the same as the old domain, still call
    // m_securityOrigin.setDomainForDOM. This will change the
    // security check behavior. For example, if a page with https:// scheme
    // assigns its current domain to document.domain, the page will
    // allow other http:// (and ports) pages in the same domain to
    // access this page. Firefox and Safari behaves like this.
    // Is this a good design?
    if (m_domain == newDomain) {
        m_securityOrigin.setDomainFromDOM(newDomain);
        return;
    }

    int oldLength = m_domain.length();
    int newLength = newDomain.length();

    // e.g. newDomain=kde.org (7) and m_domain=www.kde.org (11)

Layout test, http/tests/security/cross-frame-access-port-explicit-domain.html failed due to this.
I verified that Firefox and Safari both allow change document.document to the current domain, and treat it as set by DOM after that, so cross frame access is possible when protocol and port are different.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61954</commentid>
    <comment_count>8</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-11-21 16:20:20 -0800</bug_when>
    <thetext>More test results:

Firefox does not allow http to access https even when both domain are the same and set to themselves. Sounds reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62417</commentid>
    <comment_count>9</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-26 17:53:10 -0800</bug_when>
    <thetext>Fix landed in r28062.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17421</attachid>
            <date>2007-11-20 16:10:21 -0800</date>
            <delta_ts>2007-11-20 16:55:13 -0800</delta_ts>
            <desc>A patch with a test</desc>
            <filename>bug16073.patch</filename>
            <type>text/plain</type>
            <size>4448</size>
            <attacher name="Feng Qian">ian.eng.webkit</attacher>
            
              <data encoding="base64">SW5kZXg6IENoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBDaGFuZ2VMb2cJKHJldmlzaW9uIDI3OTMz
KQorKysgQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTYgQEAKKzIwMDctMTEt
MjAgIEZlbmcgUWlhbiA8aWFuLmVuZy53ZWJraXRAZ21haWwuY29tPgorCisgICAgICAgIFJldmll
d2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEZpeGVkIGlzc3VlIDE2MDczLgorCisg
ICAgICAgIEFkZGVkIGEgbGF5b3V0IHRlc3QuCisKKyAgICAgICAgKiBMYXlvdXRUZXN0c1xodHRw
XHRlc3RzXHNlY3VyaXR5XHJlc291cmNlc1xpZnJhbWUtaW52YWxpZC1kb21haW4tY2hhbmdlLmh0
bWw6IEFkZGVkLgorICAgICAgICAqIExheW91dFRlc3RzXGh0dHBcdGVzdHNcc2VjdXJpdHlceHNz
LURFTklFRC1pbnZhbGlkLWRvbWFpbi1jaGFuZ2UtZXhwZWN0ZWQudHh0OiBBZGRlZC4KKyAgICAg
ICAgKiBMYXlvdXRUZXN0c1xodHRwXHRlc3RzXHNlY3VyaXR5XHhzcy1ERU5JRUQtaW52YWxpZC1k
b21haW4tY2hhbmdlLmh0bWw6IEFkZGVkLgorICAgICAgICAqIFdlYkNvcmVcZG9tXERvY3VtZW50
LmNwcDoKKwogMjAwNy0xMS0yMCAgTWFyayBSb3dlICA8bXJvd2VAYXBwbGUuY29tPgogCiAgICAg
ICAgIFJldmlld2VkIGJ5IEFscCBUb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ICAgICAgICAgICAvLyBhbmQgd2UgY2hlY2sgdGhhdCBpdCdzIHRoZSBz
YW1lIHRoaW5nIGFzIG5ld0RvbWFpbgogICAgICAgICAgICAgdGVzdC5yZW1vdmUoMCwgb2xkTGVu
Z3RoIC0gbmV3TGVuZ3RoKTsKLSAgICAgICAgICAgIGlmICh0ZXN0ID09IG5ld0RvbWFpbikKKyAg
ICAgICAgICAgIGlmICh0ZXN0ID09IG5ld0RvbWFpbikgewogICAgICAgICAgICAgICAgIG1fZG9t
YWluID0gbmV3RG9tYWluOworICAgICAgICAgICAgICAgIG1fc2VjdXJpdHlPcmlnaW4uc2V0RG9t
YWluRnJvbURPTShuZXdEb21haW4pOworICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQot
Ci0gICAgbV9zZWN1cml0eU9yaWdpbi5zZXREb21haW5Gcm9tRE9NKG5ld0RvbWFpbik7CiB9CiAK
IHZvaWQgRG9jdW1lbnQ6OnNldERvbWFpbkludGVybmFsKGNvbnN0IFN0cmluZyYgbmV3RG9tYWlu
KQo=
</data>
<flag name="review"
          id="7471"
          type_id="1"
          status="+"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>