<?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>206957</bug_id>
          
          <creation_ts>2020-01-29 12:46:01 -0800</creation_ts>
          <short_desc>iFrames no longer respect referrerpolicy attribute value in ITP</short_desc>
          <delta_ts>2020-06-23 09:24:47 -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>Frames</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>https://jackwellborn.com/playground/iFrameReferrerTest/top.html?foo=bar</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jack Wellborn">w0nka</reporter>
          <assigned_to name="John Wilander">wilander</assigned_to>
          <cc>joel</cc>
    
    <cc>katherine_cheney</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1612617</commentid>
    <comment_count>0</comment_count>
    <who name="Jack Wellborn">w0nka</who>
    <bug_when>2020-01-29 12:46:01 -0800</bug_when>
    <thetext>Hello,

The link provided shows several iframes that have a referrerpolicy=&quot;same-origin&quot;. The expected behavior shown in current Safari, Firefox, and Chrome is that both the friendly and sandboxed same-origin iframes get the full referrer while the cross-origin iframes get nothing. In Safari Technology Preview Release 99, the sandboxed iframe is also getting nothing. In the very least I would like to know whether this is a bug or if downgrading document.referrer to eTLD+1 even when the owner explicitly opts to share more information is an intended part of ITP 2.3 https://webkit.org/blog/9521/intelligent-tracking-prevention-2-3/. 

Thanks.

~Jack</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612645</commentid>
    <comment_count>1</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-29 13:38:13 -0800</bug_when>
    <thetext>Is this question for document.referrer only or for HTTP referrer headers too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612648</commentid>
    <comment_count>2</comment_count>
    <who name="Jack Wellborn">w0nka</who>
    <bug_when>2020-01-29 13:42:35 -0800</bug_when>
    <thetext>Thanks. document.referrer only.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612651</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-01-29 13:48:48 -0800</bug_when>
    <thetext>&lt;rdar://problem/59005187&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612657</commentid>
    <comment_count>4</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-29 13:54:18 -0800</bug_when>
    <thetext>(In reply to Jack Wellborn from comment #2)
&gt; Thanks. document.referrer only.

Further questions – are you saying that:
1) This changed between STP 98 and 99?
2) The iframe that&apos;s seeing a downgraded document.referrer is same-origin, same-site, or cross-site?
3) The downgraded document.referrer is just the eTLD+1 or just the origin?
4) The iframe that&apos;s seeing a downgraded document.referrer is nested? If so, what does the chain of origins look like from the affected iframe all the way to the top frame?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612694</commentid>
    <comment_count>5</comment_count>
    <who name="Jack Wellborn">w0nka</who>
    <bug_when>2020-01-29 14:39:47 -0800</bug_when>
    <thetext>1) This changed between STP 98 and 99?
Not sure, this came up in a project this week. I can say that the current version of regular Safari on Mojave seems to give me the full referrer when using document.referrer from a sandboxed iframe.

2) The iframe that&apos;s seeing a downgraded document.referrer is same-origin, same-site, or cross-site?
Using the definition here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-Origin_Resource_Policy_(CORP)#Usage, I believe my example is shows sandboxed and non-sandboxed same-origin and cross-site iframes.

3) The downgraded document.referrer is just the eTLD+1 or just the origin?
Seems to be eTLD+1 (the &apos;www&apos; comes through when clicking the below). https://www.jackwellborn.com/playground/iFrameReferrerTest/top.html?foo=bar shows the referrer with 

4) The iframe that&apos;s seeing a downgraded document.referrer is nested? If so, what does the chain of origins look like from the affected iframe all the way to the top frame?
I have updated my test page to include various nested scenarios. 
https://www.jackwellborn.com/playground/iFrameReferrerTest/top.html?foo=bar

Hope this helps.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612741</commentid>
    <comment_count>6</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-29 15:56:57 -0800</bug_when>
    <thetext>Getting lost in terminology here. I have to ask for some clarifications. See inline.

(In reply to Jack Wellborn from comment #5)
&gt; 1) This changed between STP 98 and 99?
&gt; Not sure, this came up in a project this week. I can say that the current
&gt; version of regular Safari on Mojave seems to give me the full referrer when
&gt; using document.referrer from a sandboxed iframe.

There is quite a significant difference between current STP and current shipping Safari.

&gt; 2) The iframe that&apos;s seeing a downgraded document.referrer is same-origin,
&gt; same-site, or cross-site?
&gt; Using the definition here:
&gt; https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-
&gt; Origin_Resource_Policy_(CORP)#Usage, I believe my example is shows sandboxed
&gt; and non-sandboxed same-origin and cross-site iframes.

An iframe cannot be same-origin and cross-site at the same time so I assume you&apos;re talking about multiple iframes.


&gt; 3) The downgraded document.referrer is just the eTLD+1 or just the origin?
&gt; Seems to be eTLD+1 (the &apos;www&apos; comes through when clicking the below).
&gt; https://www.jackwellborn.com/playground/iFrameReferrerTest/top.html?foo=bar
&gt; shows the referrer with 

Then it&apos;s not the eTLD+1 but rather the full origin. This is what I see on your example page.

&gt; 4) The iframe that&apos;s seeing a downgraded document.referrer is nested? If so,
&gt; what does the chain of origins look like from the affected iframe all the
&gt; way to the top frame?
&gt; I have updated my test page to include various nested scenarios. 
&gt; https://www.jackwellborn.com/playground/iFrameReferrerTest/top.html?foo=bar

Thanks! I think the last two are indicating the wrong results. Look at the text output in them.

Looking at your example page (thanks for setting it up), I think the behavior is expected. Expected as in a &quot;technology preview,&quot; or things to come.

If the site (eTLD+1) of the referrer differs from the site (eTLD+1) of the iframe, document.referrer only returns the origin.

In the case of sandboxed iframes, they get the unique origin unless you give them the allow-same-origin token. This means that the comparison &quot;if the site (eTLD+1) of the referrer differs from the site (eTLD+1) of the iframe&quot; results in false since the unique origin doesn&apos;t match any other origin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1612806</commentid>
    <comment_count>7</comment_count>
    <who name="Jack Wellborn">w0nka</who>
    <bug_when>2020-01-29 18:29:35 -0800</bug_when>
    <thetext>Thanks.

&gt; An iframe cannot be same-origin and cross-site at the same time so I assume you&apos;re talking about multiple iframes. 

Am I mistaken that a website could have one iframe with same-origin source and another iframe with a cross-site source?

&gt; Then it&apos;s not the eTLD+1 but rather the full origin. This is what I see on your example page.

Ah. I misinterpreted the MDN link. I think I finally get it.

&gt; Thanks! I think the last two are indicating the wrong results. Look at the text output in them.

The second to last one is jackwellborn.com (top) &gt; wormsandviruses.com (outer iframe) &gt; jackwellborn.com (inner iframe). Because the inner iframe (jackwellborn.com) has a different origin than the outer iframe (wormsandviruses.com), it only gets the referrer origin.

The last one is jackwellborn.com (top) &gt; wormsandviruses.com (outer iframe) &gt; wormsandviruses.com (inner iframe). If I understand correctly, the inner iframe sees the full referrer because it shares the same origin of the outer iframe. Both are wormsandviruses.com.

Thanks for clarifying. Would Webkit consider supporting referrerpolicy=&quot;same-origin&quot; for sandboxed iframes? This would allow publishers to share basic data while still sandboxing contents. Furthermore, I don&apos;t think there is a data leakage/tracking concern since it&apos;s still restricted to same origin. While there is the allow-same-origin sandbox value, my understanding is that would also greatly undermine the benefits of the sandbox, especially if allow-scripts are also included. Thanks again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1613486</commentid>
    <comment_count>8</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2020-01-31 10:55:03 -0800</bug_when>
    <thetext>(In reply to Jack Wellborn from comment #7)
&gt; Thanks.
&gt; 
&gt; &gt; An iframe cannot be same-origin and cross-site at the same time so I assume you&apos;re talking about multiple iframes. 
&gt; 
&gt; Am I mistaken that a website could have one iframe with same-origin source
&gt; and another iframe with a cross-site source?
&gt; 
&gt; &gt; Then it&apos;s not the eTLD+1 but rather the full origin. This is what I see on your example page.
&gt; 
&gt; Ah. I misinterpreted the MDN link. I think I finally get it.
&gt; 
&gt; &gt; Thanks! I think the last two are indicating the wrong results. Look at the text output in them.
&gt; 
&gt; The second to last one is jackwellborn.com (top) &gt; wormsandviruses.com
&gt; (outer iframe) &gt; jackwellborn.com (inner iframe). Because the inner iframe
&gt; (jackwellborn.com) has a different origin than the outer iframe
&gt; (wormsandviruses.com), it only gets the referrer origin.
&gt; 
&gt; The last one is jackwellborn.com (top) &gt; wormsandviruses.com (outer iframe)
&gt; &gt; wormsandviruses.com (inner iframe). If I understand correctly, the inner
&gt; iframe sees the full referrer because it shares the same origin of the outer
&gt; iframe. Both are wormsandviruses.com.
&gt; 
&gt; Thanks for clarifying. Would Webkit consider supporting
&gt; referrerpolicy=&quot;same-origin&quot; for sandboxed iframes? This would allow
&gt; publishers to share basic data while still sandboxing contents. Furthermore,
&gt; I don&apos;t think there is a data leakage/tracking concern since it&apos;s still
&gt; restricted to same origin. While there is the allow-same-origin sandbox
&gt; value, my understanding is that would also greatly undermine the benefits of
&gt; the sandbox, especially if allow-scripts are also included. Thanks again.

Allowing full document.referrer for sandboxed same-site iframes without the &quot;allow-same-origin&quot; token is a reasonable ask. It&apos;s up for consideration.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>