Title: [292907] trunk
Revision
292907
Author
[email protected]
Date
2022-04-15 08:12:14 -0700 (Fri, 15 Apr 2022)

Log Message

Sandboxed iframe loads should match a service worker registration based on sandbox flags
https://bugs.webkit.org/show_bug.cgi?id=239379

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https-expected.txt: Added.

Source/WebCore:

Coverdd by updated tests.

* loader/DocumentLoader.cpp:
Sandboxed iframes have a null origin and should not be intercepted by service workers.

LayoutTests:

* TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (292906 => 292907)


--- trunk/LayoutTests/ChangeLog	2022-04-15 13:53:33 UTC (rev 292906)
+++ trunk/LayoutTests/ChangeLog	2022-04-15 15:12:14 UTC (rev 292907)
@@ -1,3 +1,12 @@
+2022-04-15  Youenn Fablet  <[email protected]>
+
+        Sandboxed iframe loads should match a service worker registration based on sandbox flags
+        https://bugs.webkit.org/show_bug.cgi?id=239379
+
+        Reviewed by Chris Dumez.
+
+        * TestExpectations:
+
 2022-04-15  Rob Buis  <[email protected]>
 
         Import css/css-sizing/aspect-ratio tests from WPT

Modified: trunk/LayoutTests/TestExpectations (292906 => 292907)


--- trunk/LayoutTests/TestExpectations	2022-04-15 13:53:33 UTC (rev 292906)
+++ trunk/LayoutTests/TestExpectations	2022-04-15 15:12:14 UTC (rev 292907)
@@ -380,7 +380,6 @@
 imported/w3c/web-platform-tests/service-workers/service-worker/update.https.html [ Pass Failure ]
 
 # Skip service worker tests that are timing out.
-imported/w3c/web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/update-bytecheck.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-include-uncontrolled.https.html [ Skip ]
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (292906 => 292907)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-15 13:53:33 UTC (rev 292906)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-15 15:12:14 UTC (rev 292907)
@@ -1,3 +1,12 @@
+2022-04-15  Youenn Fablet  <[email protected]>
+
+        Sandboxed iframe loads should match a service worker registration based on sandbox flags
+        https://bugs.webkit.org/show_bug.cgi?id=239379
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https-expected.txt: Added.
+
 2022-04-15  Rob Buis  <[email protected]>
 
         Import css/css-sizing/aspect-ratio tests from WPT

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https-expected.txt (0 => 292907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/sandboxed-iframe-fetch-event.https-expected.txt	2022-04-15 15:12:14 UTC (rev 292907)
@@ -0,0 +1,31 @@
+
+PASS Prepare a service worker.
+PASS Prepare a normal iframe.
+PASS Prepare an iframe sandboxed by <iframe sandbox="allow-scripts">.
+PASS Prepare an iframe sandboxed by <iframe sandbox="allow-scripts allow-same-origin">.
+PASS Prepare an iframe sandboxed by CSP HTTP header with allow-scripts.
+PASS Prepare an iframe sandboxed by CSP HTTP header with allow-scripts and allow-same-origin.
+PASS Fetch request from a normal iframe
+PASS Fetch request from a worker in a normal iframe
+PASS Request for an iframe in the normal iframe
+PASS Request for an sandboxed iframe with allow-scripts flag in the normal iframe
+PASS Request for an sandboxed iframe with allow-scripts and allow-same-origin flag in the normal iframe
+PASS Fetch request from iframe sandboxed by an attribute with allow-scripts flag
+PASS Fetch request from a worker in iframe sandboxed by an attribute with allow-scripts flag
+PASS Request for an iframe in the iframe sandboxed by an attribute with allow-scripts flag
+PASS Request for an sandboxed iframe with allow-scripts flag in the iframe sandboxed by an attribute with allow-scripts flag
+PASS Request for an sandboxed iframe with allow-scripts and allow-same-origin flag in the iframe sandboxed by an attribute with allow-scripts flag
+PASS Fetch request from iframe sandboxed by an attribute with allow-scripts and allow-same-origin flag
+PASS Fetch request from a worker in iframe sandboxed by an attribute with allow-scripts and allow-same-origin flag
+PASS Request for an iframe in the iframe sandboxed by an attribute with allow-scripts and allow-same-origin flag
+PASS Request for an sandboxed iframe with allow-scripts flag in the iframe sandboxed by attribute with allow-scripts and allow-same-origin flag
+PASS Request for an sandboxed iframe with allow-scripts and allow-same-origin flag in the iframe sandboxed by attribute with allow-scripts and allow-same-origin flag
+PASS Fetch request from iframe sandboxed by CSP HTTP header with allow-scripts flag
+PASS Request for an iframe in the iframe sandboxed by CSP HTTP header with allow-scripts flag
+PASS Request for an sandboxed iframe with allow-scripts flag in the iframe sandboxed by CSP HTTP header with allow-scripts flag
+PASS Request for an sandboxed iframe with allow-scripts and allow-same-origin flag in the iframe sandboxed by CSP HTTP header with allow-scripts flag
+PASS Fetch request from iframe sandboxed by CSP HTTP header with allow-scripts and allow-same-origin flag
+PASS Request for an iframe in the iframe sandboxed by CSP HTTP header with allow-scripts and allow-same-origin flag
+PASS Request for an sandboxed iframe with allow-scripts flag in the iframe sandboxed by CSP HTTP header with allow-scripts and allow-same-origin flag
+PASS Request for an sandboxed iframe with allow-scripts and allow-same-origin flag in the iframe sandboxed by CSP HTTP header with allow-scripts and allow-same-origin flag
+

Modified: trunk/Source/WebCore/ChangeLog (292906 => 292907)


--- trunk/Source/WebCore/ChangeLog	2022-04-15 13:53:33 UTC (rev 292906)
+++ trunk/Source/WebCore/ChangeLog	2022-04-15 15:12:14 UTC (rev 292907)
@@ -1,5 +1,17 @@
 2022-04-15  Youenn Fablet  <[email protected]>
 
+        Sandboxed iframe loads should match a service worker registration based on sandbox flags
+        https://bugs.webkit.org/show_bug.cgi?id=239379
+
+        Reviewed by Chris Dumez.
+
+        Coverdd by updated tests.
+
+        * loader/DocumentLoader.cpp:
+        Sandboxed iframes have a null origin and should not be intercepted by service workers.
+
+2022-04-15  Youenn Fablet  <[email protected]>
+
         ServiceWorker.postMessage() doesn't work from inside iframe
         https://bugs.webkit.org/show_bug.cgi?id=213984
         <rdar://problem/65203340>

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (292906 => 292907)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-04-15 13:53:33 UTC (rev 292906)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-04-15 15:12:14 UTC (rev 292907)
@@ -2116,6 +2116,11 @@
 #endif
 }
 
+static bool isSandboxingAllowingServiceWorkerFetchHandling(SandboxFlags flags)
+{
+    return !(flags & SandboxOrigin) && !(flags & SandboxScripts);
+}
+
 void DocumentLoader::loadMainResource(ResourceRequest&& request)
 {
     ResourceLoaderOptions mainResourceLoadOptions(
@@ -2134,13 +2139,17 @@
 
 #if ENABLE(SERVICE_WORKER)
     if (m_frame && m_frame->settings().serviceWorkersEnabled()) {
-        // The main navigation load will trigger the registration of the client.
-        if (m_resultingClientId)
-            scriptExecutionContextIdentifierToLoaderMap().remove(m_resultingClientId);
-        m_resultingClientId = ScriptExecutionContextIdentifier::generate();
-        ASSERT(!scriptExecutionContextIdentifierToLoaderMap().contains(m_resultingClientId));
-        scriptExecutionContextIdentifierToLoaderMap().add(m_resultingClientId, this);
-        mainResourceLoadOptions.clientIdentifier = m_resultingClientId;
+        if (!isSandboxingAllowingServiceWorkerFetchHandling(frameLoader()->effectiveSandboxFlags()))
+            mainResourceLoadOptions.serviceWorkersMode = ServiceWorkersMode::None;
+        else {
+            // The main navigation load will trigger the registration of the client.
+            if (m_resultingClientId)
+                scriptExecutionContextIdentifierToLoaderMap().remove(m_resultingClientId);
+            m_resultingClientId = ScriptExecutionContextIdentifier::generate();
+            ASSERT(!scriptExecutionContextIdentifierToLoaderMap().contains(m_resultingClientId));
+            scriptExecutionContextIdentifierToLoaderMap().add(m_resultingClientId, this);
+            mainResourceLoadOptions.clientIdentifier = m_resultingClientId;
+        }
     }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to