Closed Bug 1942306 Opened 7 months ago Closed 5 months ago

Add CSP support for "Create a Trusted Type Policy" for Workers

Categories

(Core :: DOM: Security, task)

task

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: fredw, Assigned: fredw)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [domsecurity-backlog], [wptsync upstream])

Attachments

(3 files, 1 obsolete file)

Follow-up of bug 1901492.

See

https://searchfox.org/mozilla-central/rev/86c208f86f35d53dc824f18f8e540fe5b0663870/dom/security/trusted-types/TrustedTypePolicyFactory.cpp#61-70
https://w3c.github.io/trusted-types/dist/spec/#should-block-create-policy
https://github.com/w3c/trusted-types/issues/574

The rough idea will be to somehow expose trusted-types directives via CSPInfo, so they can be accessed from the worker thread.

In bug 1901492, this was done for require-trusted-types-for but the data was much simpler (essentially a three states enum).

No longer blocks: 1916956, 1931293, 1931829, 1931856, 1940044

This patch rewrites ShouldTrustedTypePolicyCreationBeBlockedByCSP so
that CSP violation reports are performed in a static function
ReportPolicyCreationViolations, separate from the calculation of the
PolicyCreation result.

For requests of policy creation originating from a worker, this allows
to implement a LogPolicyCreationViolationsRunnable in order to report
violations. In follow-up patches, we will implement the calculation of
the PolicyCreation result from the CSPInfo.

Assignee: nobody → fwang
Status: NEW → ASSIGNED

This is done by exposing on CSPInfo the raw array of tt-expressions
associated to a CSPInfo::ContentSecurityPolicy [1]. Then we use a static
version of nsCSPDirective::ShouldCreateViolationForNewTrustedTypesPolicy
that relies on this raw array instead of an actual nsCSPDirective.

[1] https://w3c.github.io/trusted-types/dist/spec/#tt-expression

Attachment #9474027 - Attachment description: Bug 1942306 - Report CSP violations for "Create a Trusted Type Policy" for Workers. r=smaug → WIP: Bug 1942306 - Report CSP violations for "Create a Trusted Type Policy" for Workers. r=smaug
Attachment #9474273 - Attachment description: Bug 1942306 - Make ShouldTrustedTypePolicyCreationBeBlockedByCSP work for Workers. r=smaug,tschuster → WIP: Bug 1942306 - Make ShouldTrustedTypePolicyCreationBeBlockedByCSP work for Workers. r=smaug,tschuster
Attachment #9474410 - Attachment description: WIP: Bug 1942306 - More CSP tests for Trusted Types policy creation → Bug 1942306 - More CSP tests for Trusted Types policy creation. r=smaug
Attachment #9474027 - Attachment description: WIP: Bug 1942306 - Report CSP violations for "Create a Trusted Type Policy" for Workers. r=smaug → Bug 1942306 - Report CSP violations for "Create a Trusted Type Policy" for Workers. r=smaug
Attachment #9474273 - Attachment description: WIP: Bug 1942306 - Make ShouldTrustedTypePolicyCreationBeBlockedByCSP work for Workers. r=smaug,tschuster → Bug 1942306 - Make ShouldTrustedTypePolicyCreationBeBlockedByCSP work for Workers. r=smaug,tschuster
Pushed by fwang@igalia.com: https://hg.mozilla.org/integration/autoland/rev/951a7cba63f5 More CSP tests for Trusted Types policy creation. r=smaug https://hg.mozilla.org/integration/autoland/rev/24a402ea04d1 Report CSP violations for "Create a Trusted Type Policy" for Workers. r=smaug https://hg.mozilla.org/integration/autoland/rev/0a18e08c5a3f Make ShouldTrustedTypePolicyCreationBeBlockedByCSP work for Workers. r=tschuster
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/51629 for changes under testing/web-platform/tests
Whiteboard: [domsecurity-backlog] → [domsecurity-backlog], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
Upstream PR merged by moz-wptsync-bot
Depends on: 1935434

Apparently this breaks profiles after upgrading Firefox: bug 1958259. (My fault not noticing this!) I think we should just backout https://hg.mozilla.org/integration/autoland/rev/0a18e08c5a3f in Nightly and Beta. I think I have a potential solution that doesn't require changing the serialization format that I am going to investigate afterwards.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Since the backout is only part of what landed here, could it be done in a separate bug. Otherwise tracking what is where gets a bit tricky.

Flags: needinfo?(tschuster)

Comment on attachment 9476931 [details]
Bug 1942306 - Backout 0a18e08c5a3fc4f99f71c3621c111a7e9be01a40 for causing profile upgrade errors. r?smaug

Revision D244336 was moved to bug 1958259. Setting attachment 9476931 [details] to obsolete.

Attachment #9476931 - Attachment is obsolete: true
Flags: needinfo?(tschuster)
Status: REOPENED → RESOLVED
Closed: 5 months ago5 months ago
Resolution: --- → FIXED
Regressions: 1958858
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: