measure Trusted Types usage
Categories
(Core :: DOM: Security, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox161 | --- | fixed |
People
(Reporter: freddy, Assigned: freddy)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 3 external files, 1 obsolete file)
|
3.92 KB,
text/plain
|
Details |
Bug 2070801 evaluates Trusted Types in the CSP policy.
It would be great if we had use counters / probes for the Web APIs
- TT policies created
- TT policies invoked (createHTML, et al) manually
- ....invoked implicitly by a "default" policy
| Assignee | ||
Comment 1•2 months ago
|
||
Updated•2 months ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 2•1 month ago
•
|
||
Changing the approach a bit. We want to measure trusted-types (TT) with a specific focus on what pages on the web might be "ready to adopt" it, given a set of criteria:
- Does the page use Javascript at all?
- Does the page us innerHTML/insertAdjacentHTML/outerHTML: yes/no
- Does the page use document.write/document.writeln: yes/no
- Does the CSP use Trusted types: yes/no/reporting
- Does the code instantiate a TT policy object: yes/no
- Does the code call into the TT policy to create trusted types: yes/no
- Include library that can easily support TT: yes/no (React, Preact, Angular, Lit, maybe HTMX)
| Assignee | ||
Comment 3•1 month ago
•
|
||
This adds a Glean labeled_counter whose label encodes the full combination of readiness signals for that document:
htmlsink-{none,trusted,string}_writesink-{none,trusted,string}_ttcsp-{none,report,enforce}_strictcsp-{none,report,enforce}_created-{0,1}_used-{0,1}_lib-{0,1}_js-{0,1}
Recording depends on the pref
dom.security.trusted_types.readiness_telemetry.enabled
| Assignee | ||
Comment 4•1 month ago
•
|
||
Expose dom.security.trusted_types.readiness_telemetry.enabled through
a Nimbus setPref feature so the measurement can be sampled
| Assignee | ||
Comment 5•1 month ago
•
|
||
Set the HasTTLibrary signal, reported as the lib dimension of
security.trusted_types_readiness, when a page uses one of React, Angular,
Preact, Lit or htmx.
Detections:
- Lit: TrustedTypePolicyFactory::CreatePolicy matches the "lit-html" policy name, which Lit always creates when it loads. It is checked before the CSP check, so a blocked attempt still counts.
- React: React DOM looks up REACT_DEVTOOLS_GLOBAL_HOOK when it loads. nsGlobalWindowInner::MayResolve and DoResolve recognize that id, from a new XPCJSContext string id, and record the lookup without resolving it, ignoring Xray lookups. Defining the global goes through the resolve hook too, so at pagehide the lookup only counts if the hook still does not exist. When it does exist, the pagehide check counts it if the DevTools hook's renderers Map is non-empty, or if the page defined the hook itself, typically to disable DevTools. A hook behind an accessor, as the DevTools extension may install it, is not read and does not count.
- htmx: an htmx global property.
- Angular: an ng-version attribute anywhere in the document.
- Preact: the root vnode Preact's render() stores in its container's k expando, validated by its own undefined constructor and numeric v, at pagehide.
browser_trusted_types_libraries.js checks each detection against a page that
only reproduces its symptom, and that an empty DevTools hook or an unrelated
__k expando are not detected.
| Assignee | ||
Comment 6•1 month ago
|
||
I ran a perf test for when the pref is disabled, which seems to be acceptable. https://perf.compare/compare-results?baseRev=1a9777fb839581c2a5276adb357e36ef6eae9c1e&baseRepo=try&newRev=1bdc2d404c25a56307d0b05aa6fcbbc09c86175f&newRepo=try&framework=13&initialized=1&test_version=student-t
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 7•1 month ago
|
||
First pass at a data review
Comment 8•28 days ago
|
||
Comment on attachment 9667369 [details]
data-review.txt
Actually, starting May 7, 2024, all data collections in projects reviewed in Phabricator also perform data review in Phabricator: https://wiki.mozilla.org/Data_Collection#Firefox_Desktop.2C_Firefox_and_Focus_for_Android.2C_Gecko_.28from_May_7.2C_2024.29
In short, following what the Herald message says, code authors and code reviewers together determine what level of review is needed for new or expanded data collections. You might never need to fill out a data review request form again! (For instrumentation in projects reviewed in Phabricator, anyway)
Comment 10•22 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/c67c53312690
https://hg.mozilla.org/mozilla-central/rev/60e334e0615c
https://hg.mozilla.org/mozilla-central/rev/cddba487ff0e
Updated•17 days ago
|
Description
•