chrome-extension:// requests passed to ServiceWorker
Reported by
bobrov1...@gmail.com,
Jun 1 2018
|
|||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36 Steps to reproduce the problem: 1. Navigate to the https://jakearchibald.github.io/isserviceworkerready/demos/fetchevent/ using Chrome with any extensions installed. After the first visit, ServiceWorker will be installed. 2. During the next visit, open console to see that requests with "chrome-extension://" protocol are intercepted by ServiceWorker. What is the expected behavior? "chrome-extension://" requests couldn't be intercepted by ServiceWroker What went wrong? It looks like a security issue. Imagine situation: 1. The user has an ad-blocker extension installed. 2. The user visits malware website that installs ServiceWorker. 3. ServiceWroker intercepts all extensions requests and responds with 404 status. 4. Ad-blocker scripts failed to load, so extension doesn't work. 5. The website shows the user unwanted ads. It is just the basic scenario, who knows what could be done with that. Did this work before? N/A Chrome version: 66.0.3359.181 Channel: stable OS Version: 10.14 Flash Version:
,
Jun 2 2018
,
Jun 2 2018
,
Jun 4 2018
I can't reproduce this. Can you suggest an extension to install that exhibits this bug? Also I'm not clear whether this is actually a problem. If an extension can inject script into the page context that makes requests to a "chrome-extension://" URL, it seems reasonable for a service worker controlling that page context to see those requests. Note that the service worker can only control same-origin pages, so the scenario in comment 0 wouldn't happen (if I understand correctly). We already allow an extension to install service worker which controls that extension and sees chrome-extension:// requests made by that extension.
,
Jun 4 2018
I'm not sure this is a security bug. If an extension injects a script via a <script> tag on the page, it will execute in the main world of the page (thus having no special privileges) and will be visible to that page (it's an element in the DOM like any other). So the ability for the page to see these requests is nothing new (they could just watch DOM mutation), and even if the page could mess with the resource, it wouldn't have any privilege. meacer@, is there an attack vector I'm missing? If not, we might be able to unrestrict this. All that said, looking at this from a functionality standpoint, I'm not sure it's correct. Extensions are considered to be acting on behalf of the user agent, and thus can bypass the page (e.g., adding a <script> tag with an extension script bypasses the page's CSP). It seems like we wouldn't want to necessarily allow the page's SW to intercept these requests. Offhand, I'd say we shouldn't let the page's SW intercept any chrome-extension:-scheme requests, because I can't think of a legitimate reason to do so. falken@, WDYT? Are there any valid use cases that would break?
,
Jun 4 2018
I agree there doesn't seem to be a security problem here. From a functionality standpoint, I don't have a strong opinion in terms of use cases. I'd be motivated to implement whatever is easiest to get right. If chrome-extension:// requests are supposed to bypass CSP etc it might make it difficult to allow a SW to intercept the request while still bypassing such web security mechanisms. So I can see why just bypassing the SW might be easier. On the other hand, we already allow the SW to see chrome-extension:// requests from a chrome-extension:// page it controls, so we'd have to special-case that interception.
,
Jun 4 2018
Conceptually, I think something like
if (request_url.SchemeIs(kExtensionScheme) &&
url::Origin(initiator_url) != url::Origin(request_url)) {
// Extension requests are only visible to that extension.
HideRequest()
}
is basically the behavior we'd want. But I agree that plumbing will make this a bit tricky.
,
Jun 5 2018
Right, the way this works at Blink level today is like:
// If the URL is not http(s) or otherwise whitelisted, do not intercept the
// request. Schemes like 'blob' and 'file' are not eligible to be
// intercepted by service workers.
if (!gurl.SchemeIsHTTPOrHTTPS() && !OriginCanAccessServiceWorkers(gurl))
return nullptr;
Where in Chrome today the only white-listed scheme is chrome-extension.
If there's not really a strong reason to change things, I think we can just leave the current behavior as is for now, so I'm thinking we can just wontfixing this. Feel free to re-open or make a new (non security bug) for tracking.
,
Jun 5 2018
I think it might be worth making a (non-security) bug to track hiding these requests from pages, since it doesn't seem like desired behavior - though lower priority to fix. Before I do that, meacer@, are there any remaining security concerns here?
,
Jun 6 2018
Sounds good. Re-opening for meacer@'s input.
,
Jun 6 2018
If we are confident that SW can only intercept chrome-extension URLs that become part of the page's world, then yes I'm okay with dropping this from the security queue.
,
Jun 8 2018
Yes I believe so. Service worker works like this: - For main resource requests (basically frames and shared worker), a service worker intercepts the request if the URL falls in its scope, and the service worker controls the resulting context. - For subresource requests (every other request, it comes from a frame or worker coontext), a service worker intercepts the request if it controls the context that made the request. I don't fully understand Chrome extensions but the first interception only happens if a service worker is registered for that chrome-extension URL being navigated to, and the second interception only happens if the service worker controls the context making the request. So I'll close this. If someone can make a repro saying otherwise we can reopen.
,
Sep 14
This bug has been closed for more than 14 weeks. Removing security view restrictions. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by mea...@chromium.org
, Jun 1 2018Components: Blink>ServiceWorker Platform>Extensions
Labels: Security_Severity-Medium Security_Impact-Stable OS-Chrome OS-Fuchsia OS-Linux OS-Windows
Owner: falken@chromium.org
Status: Assigned (was: Unconfirmed)