Closed Bug 1810382 Opened 1 year ago Closed 1 year ago

webRequest filterResponseData always fail on service workers scripts

Categories

(WebExtensions :: General, defect)

Firefox 108
defect

Tracking

(firefox109 affected, firefox110 affected, firefox111 affected)

RESOLVED INVALID
Tracking Status
firefox109 --- affected
firefox110 --- affected
firefox111 --- affected

People

(Reporter: doliere, Unassigned)

References

Details

Attachments

(2 files)

Attached file Archive.zip

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko/20100101 Firefox/108.0

Steps to reproduce:

  1. Created a webExtension that makes use of the webRequest.filterResponseData API in order to manipulate service workers code.
  2. Load it in a Firefox browser, using the web-ext NPM package or manually as a temporary addon by going to about:debugging#/runtime/this-firefox
  3. Open the extension background page console (by clicking on the "Inspect" button on the top right corner of the extension name
  4. Navigated to sites that deploy service workers, i.e. https://twitter.com or https://discourse.mozilla.org/
  5. Watch the extension background page console. You should see errors being raised when the extension attempts to intercept service workers scripts responses

Actual results:

  1. Service workers responses content is never passed to the filter.ondata event where manipulation is set to be performed
  2. Instead, the filter.onerror event is constantly triggered with "Invalid request ID"
  3. See the attached archive with the extension code we used and a screenshot of the error with the service worker of twitter.com

Expected results:

  1. Service workers responses content should be viewable and manipulable within filter.ondata

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Service Workers' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Service Workers
Product: Firefox → Core
Component: DOM: Service Workers → General
Product: Core → WebExtensions

Hello,

I reproduced the issue on the latest Nightly (111.0a1/20230122211034), Beta (110.0b4/20230122190604) and Release (109.0/20230112150232) under Windows 10 x64 and Ubuntu 16.04 LTS.

With the provided extension loaded via about:debugging, accessing https://twitter.com/ logs several events in the extension console, as described in item 2 from the "Actual results" of the report.

For more details, see the attached screenshot.

Status: UNCONFIRMED → NEW
Ever confirmed: true

This is actually the intended behavior:

  • with the version of the test extension attached to this bug in comment 0, the behavior as reported is the expected one, to be able to successfully attach a StreamFilter to the response for a webrequest related to a service worker script being loaded (either the main script or imported script) through webRequest.filterResponseData the extension has to require the additional permission "webRequestFilterResponse.serviceWorkerScript" (introduced by Bug 1636629 in Firefox 95).

  • without requesting that additional webRequest permission, an error event is expected to be emitted on the StreamFilter instance returned by that webRequest.filterResponseData call

As a side note, the extension should only require the additional "webRequestFilterResponse.serviceWorkerScript" permission if it is necessary for the features that the extension intend to provide, and it should not be requested otherwise. Including the permission in an extension submitted to AMO may also require that submission to go through an additional scrutiny and reviews to confirm that the additional permission isn't being abused.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → INVALID
See Also: → CVE-2021-43540

Thanks a lot for handling the issue. I did not know about the additional permission !!!!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: