VOOZH about

URL: https://bugzilla.mozilla.org/show_bug.cgi?id=2015559

⇱ 2015559 - Enable executeScript restriction on extension pages on all channels


Closed Bug 2015559 Opened 4 months ago Closed 1 month ago

Enable executeScript restriction on extension pages on all channels

Enable executeScript restriction on extension pages on all channels
WebExtensions
General
unspecified
Unspecified
Unspecified
task
Points:
---
RESOLVED FIXED
RESOLVED
FIXED
152 Branch
Iteration:
---
a11y-review
Accessibility Severity
Performance Impact
Webcompat Priority
Webcompat Score
Tracking Status
firefox152 --- fixed
Tracking Status
relnote-firefox
thunderbird_esr115
thunderbird_esr140
firefox-esr115
firefox-esr140
firefox-esr153
firefox152
firefox153
firefox154
webextensions
---
[addons-jira][adv-main152-]
QA Whiteboard:
---
Has STR:
---
Change Request:
---
Bug Flags:
Signature:
None
This bug is publicly visible.

 
👁 Image
non dynamic code execution blocked too
12.26 KB, image/png
Details
48 bytes, text/x-phabricator-request
Details | Review

As a followup to Bug 2011234, we plan to enable the restriction on all channel as part of the Firefox 152 cycle and let it ride the train (in the meantime the restriction is enabled on Nightly builds by default and a deprecation warning logged in the target extension page when the restriction is being hit).

Assignee

Updated

4 months ago
See Also: → 2016161
Assignee

Updated

3 months ago
Depends on: 1685123

The bug 2011234 says it's blocking dynamic code execution, but from what I can see, even fixed code execution is blocked.
Is this really intended behavior?

Assignee

Comment 2

2 months ago

(In reply to juraj.masiar from comment #1)

The bug 2011234 says it's blocking dynamic code execution, but from what I can see, even fixed code execution is blocked.
Is this really intended behavior?

Yes, this is intentional. Access control is based on the target of the execution, and we wanted to consistently apply the change to the all methods without exceptions. And unlike tabs.executeScript, we never documented that scripting.executeScript allows execution in extension documents. Here is the relevant diff of the documentation change:

But why restrict it for the modern scripting namespace at all?
It doesn't allow any dynamic code execution, that was the whole point of MV3.

Being able to use "any" extension API on your own extension tabs is a huge consistency help.
The fact that it wasn't documented is not a good argument as most API doesn't state this, because why should they get a special treatment? It's like updating tabs.setZoom documentation and writing that it works on extensions pages...

I understand the security reasoning in the tabs namespace, but I don't see it helping anyone on already secure scripting namespace.
All I see now is a lot of code I need to change in multiple of my addons :(, and I'm sure it's not just me.

Assignee

Updated

1 month ago
Blocks: 2039393
Assignee: nobody → rob
Status: NEW → ASSIGNED
Assignee

Comment 5

1 month ago

dev-doc-needed: The deprecation announced in 149 is now enforced by default in 152, so it should be added to https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/152

(not to be documented on MDN, but good to know:) Users who discover too late of the breakage due to the extension authors having missed the deprecation announcement can temporarily get their extension working again by flipping the preference back to true. This preference is not expected to be long-lived, however! It will be removed in bug 2039393.

For future reference, here is the analysis of telemetry data to assess the potential impact of the deprecation.
I looked at telemetry (added in bug 2011234) to detect affected extensions, from the past two weeks:

I took a sample of 64 add-ons with at least 100 users among the items at https://sql.telemetry.mozilla.org/queries/119850 and analyzed them.
Most of the injections are unintentional. Only 7 were conclusively affected by the change.

Keywords: dev-doc-needed

Comment 7

1 month ago
bugherder
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

Comment 8

1 month ago

Release note added in PR [https://github.com/mdn/content/pull/44123) #44123

Assignee

Comment 9

1 month ago

(In reply to juraj.masiar from comment #3)

But why restrict it for the modern scripting namespace at all?
It doesn't allow any dynamic code execution, that was the whole point of MV3.

Mainly for consistency within the APIs and across browsers. insertCSS is not as dangerous either, but we still treat it the same as executeScript. And with this enforcement, we also don't need to be concerned with content scripts having access to higher privileged APIs than they usually do.

The data I analyzed (comment 5) shows that the vast majority of executions in extension documents are not intentional, and those that are were able to migrate to alternatives. That comment only enumerates extensions "negatively" impacted by the deprecation. An example of an extension that would positively have been impacted is shown in https://bugzilla.mozilla.org/show_bug.cgi?id=2011234#c2

Whiteboard: [addons-jira] → [addons-jira][adv-main-152-]
Whiteboard: [addons-jira][adv-main-152-] → [addons-jira][adv-main152-]
You need to log in before you can comment on or make changes to this bug.