<?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>223848</bug_id>
          
          <creation_ts>2021-03-27 21:30:23 -0700</creation_ts>
          <short_desc>CSP: iframe with sandbox=&quot;allow-scripts&quot; does not respect default-src &apos;self&apos; policy</short_desc>
          <delta_ts>2023-10-06 06:06:23 -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 14</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 10.15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://jsfiddle.net/4hLdygm9/1/</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="Daniel">hi</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1744586</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel">hi</who>
    <bug_when>2021-03-27 21:30:23 -0700</bug_when>
    <thetext>I have an iframe defined as follows:

&lt;iframe src=&quot;https://cloudflare-ipfs.com/ipfs/QmUiDhFZeFnJvHgxGbwPucT8kyZvAzBsFFA12vPNxfsP6u/&quot; sandbox=&quot;allow-scripts&quot; /&gt;

The embedded page contains a CSP meta tag:

&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;default-src &apos;self&apos; &apos;unsafe-inline&apos;;&quot;&gt;

The page contains a script tag like this, which should be allowed by default-src &apos;self&apos;:

&lt;script src=&quot;test.js&quot;&gt;&lt;/script&gt;

However, this error is thrown:
Refused to load https://cloudflare-ipfs.com/ipfs/QmPAQqymGn4GTNmfUqof2xtQNJU7GHRcvcvaPSJSzhNoTw/style.css because it appears in neither the style-src directive nor the default-src directive of the Content Security Policy.

If I add &quot;allow-same-origin&quot; to the iframe&apos;s sandbox attribute, the error goes away.

I&apos;ve set up a working example here:
https://jsfiddle.net/4hLdygm9/1/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744587</commentid>
    <comment_count>1</comment_count>
    <who name="Daniel">hi</who>
    <bug_when>2021-03-27 21:31:54 -0700</bug_when>
    <thetext>Apologies, the error being thrown is actually this one:

Refused to load https://cloudflare-ipfs.com/ipfs/QmUiDhFZeFnJvHgxGbwPucT8kyZvAzBsFFA12vPNxfsP6u/test.js because it appears in neither the script-src directive nor the default-src directive of the Content Security Policy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1746892</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-04-04 21:23:01 -0700</bug_when>
    <thetext>&lt;rdar://problem/76205075&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1748160</commentid>
    <comment_count>3</comment_count>
    <who name="Smoley">smoley</who>
    <bug_when>2021-04-07 17:06:45 -0700</bug_when>
    <thetext>Thanks for filing, I&apos;m seeing this error on Safari 13.1.2 as well as TOT 14.2 using the provided test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1983186</commentid>
    <comment_count>4</comment_count>
    <who name="Daniel">hi</who>
    <bug_when>2023-10-06 06:06:14 -0700</bug_when>
    <thetext>Randomly thought of this bug from a while back and it seems to be fixed on Safari Version 17.0 (19616.1.27.211.1)!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>