Skip to content

Truly independent web browser

LibWeb: Never block blob URLs as mixed content

Andreas Klingc5783c6a3df7
diff --git a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp
index b162a2b8343..50c26659671 100644
--- a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp
+++ b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp
@@ -96,6 +96,11 @@ static bool target_browsing_context_is_top_level(Fetch::Infrastructure::Request
return environment && environment->target_browsing_context == Context::TargetBrowsingContext::TopLevel;
}
+static bool is_blob_url(URL::URL const& url)
+{
+ return url.scheme() == "blob"sv;
+}
+
// https://w3c.github.io/webappsec-mixed-content/#should-block-fetch
Fetch::Infrastructure::RequestOrResponseBlocking should_fetching_request_be_blocked_as_mixed_content(Fetch::Infrastructure::Request& request)
{
@@ -109,6 +114,11 @@ Fetch::Infrastructure::RequestOrResponseBlocking should_fetching_request_be_bloc
// its URL, so that a redirect to an insecure URL is blocked as well.
|| SecureContexts::is_url_potentially_trustworthy(request.current_url()) == SecureContexts::Trustworthiness::PotentiallyTrustworthy
+ // INTEROP: A blob URL is resolved from the blob URL store and never reaches the network. A blob URL created in
+ // a context with an opaque origin, such as a sandboxed iframe, is not potentially trustworthy, but
+ // is still never treated as mixed content.
+ || is_blob_url(request.current_url())
+
// FIXME: 3. The user agent has been instructed to allow mixed content, as described in § 7.2 User Controls).
|| false
@@ -134,6 +144,9 @@ Web::Fetch::Infrastructure::RequestOrResponseBlocking should_response_to_request
// 2. response’s url is a potentially trustworthy URL.
|| (response.url().has_value() && SecureContexts::is_url_potentially_trustworthy(response.url().value()) == SecureContexts::Trustworthiness::PotentiallyTrustworthy)
+ // INTEROP: A blob URL is never treated as mixed content. See should_fetching_request_be_blocked_as_mixed_content().
+ || (response.url().has_value() && is_blob_url(response.url().value()))
+
// FIXME: 3. The user agent has been instructed to allow mixed content, as described in § 7.2 User Controls).
|| false
diff --git a/Tests/LibWeb/Text/expected/Worker/blob-worker-in-sandboxed-iframe.txt b/Tests/LibWeb/Text/expected/Worker/blob-worker-in-sandboxed-iframe.txt
index 88f352ca8ec..87679512ca8 100644
--- a/Tests/LibWeb/Text/expected/Worker/blob-worker-in-sandboxed-iframe.txt
+++ b/Tests/LibWeb/Text/expected/Worker/blob-worker-in-sandboxed-iframe.txt
@@ -1 +1 @@
-Worker in sandboxed iframe: failed to load
+Worker in sandboxed iframe: ran