<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23219</bug_id>
          
          <creation_ts>2013-09-11 20:35:06 +0000</creation_ts>
          <short_desc>contentDocument on iframe, object, frame, etc, should do a security check (and then, if that&apos;s the last of the ways you can get to Document, we can remove the security checks on Document)</short_desc>
          <delta_ts>2013-11-12 21:53:12 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-object-element</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bobbyholley</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93270</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-09-11 20:35:06 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#the-object-element
Complete: http://www.whatwg.org/c#the-object-element
Referrer: 

Comment:
contentDocument on iframe, object, frame, etc, should do a security check (and
then, if that&apos;s the last of the ways you can get to Document, we can remove
the security checks on Document)

Posted from: 2620:0:1000:167c:5df3:e6f0:15bb:7617 by ian@hixie.ch
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1612.2 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93448</commentid>
    <comment_count>1</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-09-16 19:12:48 +0000</bug_when>
    <thetext>Mozilla did this in [1] a little while back. Please let me know if we&apos;re at all divergent from the desired behavior here.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=829872</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96161</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-12 03:31:07 +0000</bug_when>
    <thetext>So Safari and Firefox return null, Chrome throws a security exception.

Throwing a security exception does seem more consistent with other places where we try to do this kind of thing. Firefox throws an exception for window.document, for instance. bholley, would you be willing to move Firefox to throwing an exception for cross-origin contentDocument instead of returning null?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96162</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-12 03:53:48 +0000</bug_when>
    <thetext>Throwing an exception during a basic for/in loop over some random object from your own web page seems like a bit of an antipattern to me...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96184</commentid>
    <comment_count>4</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-11-12 16:49:58 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #2)
&gt; Throwing a security exception does seem more consistent with other places
&gt; where we try to do this kind of thing. Firefox throws an exception for
&gt; window.document, for instance.

You mean getting |document| off a cross-origin |window| object? That seems very different from getting |contentDocument| off a same-origin iframe element.

As boris noted, I think it would be a shame if enumerating random HTML Elements could cause a security exception.

&gt; bholley, would you be willing to move Firefox
&gt; to throwing an exception for cross-origin contentDocument instead of
&gt; returning null?

Totally willing as an implementor if everyone decides that these are optimal semantics, but I&apos;m not convinced that they are.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96207</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-12 21:49:53 +0000</bug_when>
    <thetext>Fair enough. I&apos;ll make it return null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96208</commentid>
    <comment_count>6</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-11-12 21:50:49 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8272.
Check-in comment: Change iframe, frame, and object.contentDocument to return null when cross-origin documents are involved.
http://html5.org/tools/web-apps-tracker?from=8271&amp;to=8272</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96210</commentid>
    <comment_count>7</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-11-12 21:53:12 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8273.
Check-in comment: Remove security checks on Document since there should now be no way to get to a Document from another origin.
http://html5.org/tools/web-apps-tracker?from=8272&amp;to=8273</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>