Closed Bug 1947732 Opened 6 months ago Closed 4 months ago

Trusted Types policies should not apply to isolated WebExtension content scripts

Categories

(Core :: DOM: Security, task)

task

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: tschuster, Assigned: tschuster)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(3 files)

We make some effort to exempt extensions from page CSPs (bug 1267027), we should consider doing the same for Trusted Types, otherwise pages could unduly restrict the functionality of extensions.

I verified that currently Trusted Types can prevent WebExtension content scripts from using innerHTML and other sinks to inject content into the page. This applies to both ISOLATED and MAIN world content scripts.

I have a patch that would allow us to bypass Trusted Types completely for isolated content scripts by checking the nsIPrincipal when e.g. calling the innerHTML setter. (We could use the same mechanism for UA widgets, which would be an alternative to the changes in bug 1961770)
I think for main world content scripts we can't do anything, because they just look/behave like normal scripts inside the page.

Thank you for working on this, Tom.

Attachment #9480583 - Attachment description: WIP: Bug 1947732 - Bypass Trusted Types for (isolated) WebExtension content scripts. → WIP: Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantString
Assignee: nobody → tschuster
Blocks: 1267027
See Also: → 1406278
No longer blocks: 1267027
Attachment #9480583 - Attachment description: WIP: Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantString → Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantString. r?smaug
Attachment #9481157 - Attachment description: WIP: Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantAttributeValue → Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantAttributeValue. r?smaug
Attachment #9481172 - Attachment description: WIP: Bug 1947732 - Exempt (isolated) WebExtension content scripts from trusted types policies → Bug 1947732 - Exempt (isolated) WebExtension content scripts from trusted types policies. r?smaug!,#extension-reviewers!
Summary: Trusted Types policies should probably not apply to WebExtension content scripts → Trusted Types policies should not apply to isolated WebExtension content scripts
Depends on: 1963277
Pushed by tschuster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/627d49221806 Provide nsIPrincipal to GetTrustedTypesCompliantString. r=smaug https://hg.mozilla.org/integration/autoland/rev/b4723229d8d0 Provide nsIPrincipal to GetTrustedTypesCompliantAttributeValue. r=smaug https://hg.mozilla.org/integration/autoland/rev/3566d94bcda7 Exempt (isolated) WebExtension content scripts from trusted types policies. r=smaug,extension-reviewers,robwu
QA Whiteboard: [qa-triage-done-c141/b140]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: