Skip to content
Snippets Groups Projects
Commit 2a3c93ea authored by Justin Lulejian's avatar Justin Lulejian Committed by Chromium LUCI CQ
Browse files

[M126-LTS][Extensions][ServiceWorker] Skip worker for isolated world module fetch

Before this change, an isolated world (e.g. extension content script,
but also others) could dynamically import a script from an accessible
resource (for extensions this is possible with web accessible
resources and a matching site). When this occurs a web service worker
could intercept that request and respond with arbitrary content.

After this change, isolated world module requests skip triggering the
worker fetch handler. This includes extension content scripts, but also
includes any other scripts that execute in the isolated world context.

(cherry picked from commit 2c501634)

Bug: 371011220
Change-Id: I37eda47324b6933a93d2a44792a06ff91399981f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5917013
Auto-Submit: Justin Lulejian <jlulejian@chromium.org>
Commit-Queue: Justin Lulejian <jlulejian@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1365918}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5962436


Commit-Queue: Dan Clark <daniec@microsoft.com>
Auto-Submit: Roger Felipe Zanoni da Silva (xWF) <rzanoni@google.com>
Reviewed-by: default avatarDan Clark <daniec@microsoft.com>
Reviewed-by: default avatarJustin Lulejian <jlulejian@chromium.org>
Reviewed-by: default avatarMohamed Omar <mohamedaomar@google.com>
Owners-Override: Mohamed Omar <mohamedaomar@google.com>
Cr-Commit-Position: refs/branch-heads/6478@{#1991}
Cr-Branched-From: e6143acc-refs/heads/main@{#1300313}
parent b5206c95
No related branches found
No related tags found
No related merge requests found
......@@ -153,12 +153,20 @@ void ModuleScriptLoader::FetchInternal(
url_ = module_request.Url();
#endif
DOMWrapperWorld& request_world = modulator_->GetScriptState()->World();
// Prevents web service workers from intercepting isolated world dynamic
// script imports requests and responding with different contents.
// TODO(crbug.com/1296102): Link to documentation that describes the criteria
// where module imports are handled by service worker fetch handler.
resource_request.SetSkipServiceWorker(request_world.IsIsolatedWorld());
// <spec step="9">Set request 's destination to the result of running the
// fetch destination from module type steps given destination and
// moduleType.</spec>
SetFetchDestinationFromModuleType(resource_request, module_request);
ResourceLoaderOptions options(&modulator_->GetScriptState()->World());
ResourceLoaderOptions options(&request_world);
// <spec step="11">Set request's initiator type to "script".</spec>
options.initiator_info.name = fetch_initiator_type_names::kScript;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment