<?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>218086</bug_id>
          
          <creation_ts>2020-10-22 09:59:25 -0700</creation_ts>
          <short_desc>Same domain sandboxed iframe events blocked from parent listener without allow-scripts</short_desc>
          <delta_ts>2025-02-09 04:50:33 -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>Safari 14</version>
          <rep_platform>All</rep_platform>
          <op_sys>macOS 10.15</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></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="Caleb Cordry">ccordry</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>opendarwin</cc>
    
    <cc>phil</cc>
    
    <cc>r89534217610</cc>
    
    <cc>smoley</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1700692</commentid>
    <comment_count>0</comment_count>
    <who name="Caleb Cordry">ccordry</who>
    <bug_when>2020-10-22 09:59:25 -0700</bug_when>
    <thetext>If a same domain iframe is created using `srcdoc` with `sandbox=allow-same-origin` and an event listener is created from the parent page e.g.

const img = iframe.contentDocument.querySelector(&apos;img&apos;); 
img.addEventListener(&apos;click&apos;, callback)

The event will be blocked in Safari with the error `Blocked script execution in &apos;about:srcdoc&apos; because the document&apos;s frame is sandboxed and the &apos;allow-scripts&apos; permission is not set.` In other modern browsers the event will be received by the parent page. Adding &apos;allow-scripts&apos; will allow the parent to receive the event.

We believe according to the spec https://html.spec.whatwg.org/multipage/webappapis.html#sandboxScriptBlocked these events should not be blocked as they execute in the parent window and not the sandboxed iframe window.

You can find a demo at: https://sandboxed-listener.glitch.me/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1700738</commentid>
    <comment_count>1</comment_count>
    <who name="Smoley">smoley</who>
    <bug_when>2020-10-22 10:55:29 -0700</bug_when>
    <thetext>Thanks for filing, I can reproduce this on Safari 12.1.2 as well as Safari Beta version 14.0.1 using the linked test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1700739</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-10-22 10:55:45 -0700</bug_when>
    <thetext>&lt;rdar://problem/70580282&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1726344</commentid>
    <comment_count>3</comment_count>
    <who name="Smoley">smoley</who>
    <bug_when>2021-02-05 18:06:30 -0800</bug_when>
    <thetext>*** Bug 221283 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886533</commentid>
    <comment_count>4</comment_count>
    <who name="Phil Freo">phil</who>
    <bug_when>2022-07-25 11:00:25 -0700</bug_when>
    <thetext>This bug also exists in Safari Version 15.5.

This bug has a negative affect on web security because Safari&apos;s behavior means it&apos;s harder for developers to utilize sandboxed iframes to block scripts from within the iframe, if the external page still needs any scripting control.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2093280</commentid>
    <comment_count>5</comment_count>
    <who name="rb">r89534217610</who>
    <bug_when>2025-02-09 04:50:33 -0800</bug_when>
    <thetext>It is still present on the latest iOS and really undermines the security when working with iframes.

Current workaround if you&apos;re using `srcdoc` is prepending CSP meta tag to block script executions:

```html
&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;script-src &apos;none&apos;;&quot;&gt;
```</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>