<?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>15936</bug_id>
          
          <creation_ts>2007-11-10 16:45:31 -0800</creation_ts>
          <short_desc>Overly permissive frame navigation allows password theft</short_desc>
          <delta_ts>2008-01-03 22:28:05 -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>Frames</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://crypto.stanford.edu/~abarth/research/webkit/adsense.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Adam Barth">abarth</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bdakin</cc>
    
    <cc>collinj</cc>
    
    <cc>sam</cc>
    
    <cc>yuzhu.shen</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>60864</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2007-11-10 16:45:31 -0800</bug_when>
    <thetext>WebKit&apos;s frame navigation policy is overly permissive, allowing a web attacker to steal passwords from many sites including Google and several banks.

WebKit allows any page to navigate subframes of any other page.  If a site embeds a password field in an frame, a malicious web site operator can navigate that frame to his site and steal user passwords.  

The steps below can be used to reproduce the issue:

1) Navigate to http://crypto.stanford.edu/~abarth/research/webkit/adsense.html
2) Click &quot;Open AdSense in a new window.&quot;
3) Click &quot;Navigate the AdSense login frame.&quot;
4) Notice the password field in the AdSense window has been replaced by content of the attackers choice.  The address bar reads &quot;www.google.com&quot; and the lock icon is intact.

The frame navigation policy in Firefox 2 was developed in 1999 in response to a similar attack against CitiBank [1].  Their policy is as follows:

* Allow the navigation if the source and target frames contained in the same window.
* Allow if the source frame can script the target frame or one of its ancestors in the frame hierarchy.

Internet Explorer 7 is more strict than Firefox 2.  For example, IE7 forbids the navigation from the lower frame in [2] whereas Firefox 2 permits it.  From what we can tell, IE7 is enforcing the following policy:

* Allow if the source frame can script the target frame or one of its
ancestors in the frame hierarchy.

The HTML5 spec [3] is the most strict.  From our reading, it forbids both of the navigations in [4], whereas all the browsers we&apos;ve tested allow both.

We recommend WebKit implement the same frame navigation policy as Internet Explorer 7:

* Allow if the source frame can script the target frame or one of its
ancestors in the frame hierarchy.

References:

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=13871
[2] http://crypto.stanford.edu/~abarth/research/nav/frame1.html
[3] http://www.whatwg.org/specs/web-apps/current-work/#the-rules
[4] http://xenon.stanford.edu/~abarth/research/nav/frame1.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60868</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-11-10 17:24:39 -0800</bug_when>
    <thetext>&lt;rdar://problem/5592988&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62406</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-26 16:16:29 -0800</bug_when>
    <thetext>Fixed in r28056.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62434</commentid>
    <comment_count>3</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2007-11-27 00:11:59 -0800</bug_when>
    <thetext>Thanks for addressing this quickly.  According to the comments in your patch, you implemented the following frame navigation policy:

  The navigation change is safe if the active frame is: 
   - in the same security domain (satisfies same-origin policy) 
   - the opener frame 
   - an ancestor or a descendant in frame tree hierarchy 

I&apos;m curious why you decided on this policy.  It doesn&apos;t match Firefox or Internet Explorer 7.  For example, the &quot;Navigate middle frame&quot; link at &lt;http://xenon.stanford.edu/~abarth/research/nav/frame1.html&gt; is forbidden by IE7 but allowed by this policy.

If we can reach a consensus frame navigation policy among the major browsers, then we can standardize the behavior as part of HTML5 and the web at large will benefit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62474</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-27 09:31:21 -0800</bug_when>
    <thetext>I allowed navigating the ancestor frame because when I tested IE I noticed it allowed the parent frame (in another domain) to be navigated.  It seems my testing and analysis was too limited and the behavior of IE is actually that only the frame at the top of the hierarchy is  allowed to be navigated.  Does this match your findings?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62508</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2007-11-27 13:22:18 -0800</bug_when>
    <thetext>&gt; the behavior of IE is actually that only the frame at the top of the
&gt; hierarchy is allowed to be navigated.  Does this match your findings?

Yes, that&apos;s my current understanding as well.  I&apos;ll do some more systematic testing of IE7 and report back by the end of the week.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62620</commentid>
    <comment_count>6</comment_count>
      <attachid>17584</attachid>
    <who name="Collin Jackson">collinj</who>
    <bug_when>2007-11-28 17:26:43 -0800</bug_when>
    <thetext>Created attachment 17584
Updates the frame navigation policy to match Internet Explorer 7 (single window)

We did some more exhaustive testing of frame navigation in Internet Explorer 7 and wrote a patch to update WebKit to match IE7.

Here is a test framework that we created: http://w3sim.com/frames/
Here are the results on IE7: http://w3sim.com/frames/screenshots/ie7-single.png
Here are the results on the nightly WebKit: http://w3sim.com/frames/screenshots/webkit-2007-11-27-single.png
Here are the results after the attached patch: http://w3sim.com/frames/screenshots/webkit-patched-single.png

Our current understanding of the IE7 policy is that a active frame can navigate a target frame (in the same window) if:

* The target frame is the top-level frame
* The active frame is in the same origin of the target frame or any of its ancestors

So far we have only tried navigating frames within a single window. We&apos;re going to work on the multi-window case next.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62636</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-11-28 21:34:43 -0800</bug_when>
    <thetext>Reopening to mark change for review.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62705</commentid>
    <comment_count>8</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-29 10:43:17 -0800</bug_when>
    <thetext>Adam/Collin,
Have you tested any special handling of the prenamed targets _top and _parent?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62706</commentid>
    <comment_count>9</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2007-11-29 10:54:46 -0800</bug_when>
    <thetext>&gt; Have you tested any special handling of the prenamed targets _top and _parent?

Not yet, but that&apos;s a good idea.

We also learned last night that a frame&apos;s opener can change after it is created, which complicates the multi-window tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62728</commentid>
    <comment_count>10</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-29 15:56:21 -0800</bug_when>
    <thetext>After some testing of the opener frame behavior I have come to the conclusion that a simpler policy may be possible.  The policy is:

 The navigation change is safe if the active frame is:
   - in the same security origin as the target or one of the target&apos;s ancestors
Or the target frame is:
   - a top-level frame frame in the frame hierarchy

Thoughts?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62735</commentid>
    <comment_count>11</comment_count>
      <attachid>17584</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-29 17:12:31 -0800</bug_when>
    <thetext>Comment on attachment 17584
Updates the frame navigation policy to match Internet Explorer 7 (single window)

I have an updated version of this that I will post soon.  r- for now</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62757</commentid>
    <comment_count>12</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2007-11-29 21:21:32 -0800</bug_when>
    <thetext>Additional fix landed in r28225.  If you think the policy is still incorrect please let me know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62801</commentid>
    <comment_count>13</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2007-11-30 11:09:40 -0800</bug_when>
    <thetext>r28225 looks good to us, and performs the same as IE7 on our test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66123</commentid>
    <comment_count>14</comment_count>
    <who name="Yuzhu Shen">yuzhu.shen</who>
    <bug_when>2008-01-03 05:06:22 -0800</bug_when>
    <thetext>According to the policy implemented in current WebKit, I&apos;ve created a scenario in which various browsers act differently.

Assume that the following files are located at http://aaa.bbb.com/
Note: If you want to try out this example, change the value of document.domain accordingly in these files! It should be a suffix of the real domain in which these files reside.
====================================
&lt;!-- navigation.htm --&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script language=&quot;javascript&quot;&gt;document.domain=&apos;bbb.com&apos;;&lt;/script&gt;
&lt;/head&gt;
&lt;frameset name=&quot;main&quot; cols=&quot;503,*&quot;&gt;
	&lt;frame name=&quot;left&quot; src=&quot;left.htm&quot; /&gt;
	&lt;frame name=&quot;right&quot; src=&quot;right.htm&quot; /&gt;
&lt;/frameset&gt;
&lt;/html&gt;
================================
&lt;!-- left.htm --&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;base target=&apos;right&apos;&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;a href=&apos;helloWorld.htm&apos;&gt;HelloWorld&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
=================================
&lt;!-- right.htm --&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;script language=&quot;javascript&quot;&gt;document.domain=&apos;bbb.com&apos;;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
=================================
&lt;!-- helloWorld.htm --&gt;
&lt;html&gt;
&lt;body&gt;
    &lt;h1&gt;Hello World!&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;
=================================

If you click the &quot;HelloWorld&quot; link:
IE7: will open the link in a new tab instead of the target frame.
IE6, Firefox2/3, Safari 3.0.3: will open the link in the target frame.
Current WebKit: will do nothing.

This problem affects a popular forum in China: http://dzh.mop.com
In this forum, if you click a link in the left panel, current WebKit will not open the link. (Due to some other reasons, IE7 works fine with this site.)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66131</commentid>
    <comment_count>15</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2008-01-03 09:07:05 -0800</bug_when>
    <thetext>(In reply to comment #14)
&gt; According to the policy implemented in current WebKit, I&apos;ve created a scenario
&gt; in which various browsers act differently.

Please open a new bug for this issue.  Thanks!

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66174</commentid>
    <comment_count>16</comment_count>
    <who name="Yuzhu Shen">yuzhu.shen</who>
    <bug_when>2008-01-03 22:28:05 -0800</bug_when>
    <thetext>bug 16727 has been created to track this problem.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17584</attachid>
            <date>2007-11-28 17:26:43 -0800</date>
            <delta_ts>2007-11-29 17:12:31 -0800</delta_ts>
            <desc>Updates the frame navigation policy to match Internet Explorer 7 (single window)</desc>
            <filename>navigation.patch</filename>
            <type>text/plain</type>
            <size>2703</size>
            <attacher name="Collin Jackson">collinj</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvbG9hZGVyL0ZyYW1lTG9hZGVyLmNwcAo9PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBXZWJD
b3JlL2xvYWRlci9GcmFtZUxvYWRlci5jcHAJKHJldmlzaW9uIDI4MT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bWUgd2l0aCBVUkwgJXMgZnJvbSBm
cmFtZSB3aXRoIFVSTCAlcy5cbiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgdGFyZ2V0RG9jdW1lbnQtPlVSTCgpLnV0ZjgoKS5kYXRhKCksIGFjdGl2ZURvY3VtZW50
LT5VUkwoKS51dGY4KCkuZGF0YSgpKTsK
</data>
<flag name="review"
          id="7567"
          type_id="1"
          status="-"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>