Closed Bug 1756758 Opened 2 years ago Closed 2 years ago

Add support for `restrictSchemes` in `registerContentScripts()` (MV2)

Categories

(WebExtensions :: General, enhancement, P4)

enhancement

Tracking

(firefox104 fixed)

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: willdurand, Assigned: willdurand)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Attachments

(1 file)

We use parseMatchPatterns to validate the matches option in scripting.registerContentScripts(). We should configure the restrictSchemes option (depending on extension.restrictSchemes?) and add test coverage for that.

Given this would allow "privileged callers to run scripts literally anywhere", it is low priority.

Whiteboard: [addons-jira]
Assignee: nobody → wdurand
Status: NEW → ASSIGNED

The patch above introduces support for restrictSchemes in the scripting API, but that only works in MV2, because the optional permission mechanism lacks restrictSchemes flags in various places (which is required in MV3, whereas MV2 extensions also have the option of using mandatory host permissions, where restrictSchemes is supported)).

In order to meaningfully support restrictSchemes in the scripting API with MV3, we'd also need to set the flags where instances of MatchPattern (including MatchPatternSet constructors with string input) are created.

See Also: → 1766915, 1765828

Any host permissions outside of permitted schemes[1] should not be included in about:addons and should not be contained in ExtensionPermissions. They should be granted automatically at extension startup. These are privileged extensions and are primarily going to be using urls internal to firefox. They'll have internal needs for those in order to operate, we shouldn't extend user control to those.

Given that, I think that a) it doesn't matter that it's MV2 only right now, and b) a followup bug should be filed to grant permission for privileged schemes here[2].

[1] https://searchfox.org/mozilla-central/rev/ffb50da3ca89100b6ae5054cfe69c187679515f0/toolkit/components/extensions/MatchPattern.cpp#227-228
[2] https://searchfox.org/mozilla-central/rev/ffb50da3ca89100b6ae5054cfe69c187679515f0/toolkit/components/extensions/Extension.jsm#1319-1321

Summary: Add support for `restrictSchemes` in `registerContentScripts()` → Add support for `restrictSchemes` in `registerContentScripts()` (MV2)
Blocks: 1780507
Attachment #9278754 - Attachment description: Bug 1756758 - Add support for `restrictSchemes` in `registerContentScripts()`. r?robwu! → Bug 1756758 - Add support for `restrictSchemes` in `registerContentScripts()` (MV2). r?mixedpuppy,robwu
Pushed by wdurand@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5a336820e40b
Add support for `restrictSchemes` in `registerContentScripts()` (MV2).  r=mixedpuppy

(In reply to Shane Caraveo (:mixedpuppy) from comment #3)

They'll have internal needs for those in order to operate, we shouldn't extend user control to those.

I've came to the same conclusion as well.

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: