Skip to content

Commit 0b6363d

Browse files
committed
FF145 Relnote: Trusted Types early beta
1 parent 98c224e commit 0b6363d

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

files/en-us/mozilla/firefox/experimental_features/index.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -366,26 +366,22 @@ The {{domxref("CloseWatcher")}} interface allows developers to implement UI comp
366366
### Trusted Types API
367367

368368
The [Trusted Types API](/en-US/docs/Web/API/Trusted_Types_API) provides mechanisms to ensure that functions that can potentially be used as vectors for XSS attacks are only able to be called with data that has been validated or sanitized.
369+
The API has been implemented and is enabled in early beta releases ([Firefox bug 1992941](https://bugzil.la/1992941)).
369370

370-
> [!NOTE]
371-
> At the time of writing not enough of the API has been implemented for it to be effectively testable.
372-
> This note will be removed once it is ready.
371+
This includes (non-exhaustively):
373372

374-
This subset of the API has been implemented:
375-
376-
- {{domxref("TrustedTypePolicyFactory")}}:
377-
- {{domxref("TrustedTypePolicyFactory/getAttributeType", "getAttributeType()")}} and {{domxref("TrustedTypePolicyFactory/getPropertyType", "getPropertyType()")}} ([Firefox bug 1917783](https://bugzil.la/1917783), [Firefox bug 1917784](https://bugzil.la/1917784)).
378-
- The {{domxref("Document.write()", "write()")}} and {{domxref("Document.writeln()","writeln()")}} methods of the {{domxref("Document")}} interface now accept {{domxref("TrustedHTML")}} objects as parameters, in addition to strings. ([Firefox bug 1906301](https://bugzil.la/1906301)).
379-
- The {{domxref("HTMLScriptElement.text","text")}}, {{domxref("HTMLElement.innerText","innerText")}}, and {{domxref("Node.textContent","textContent")}} properties of the {{domxref("HTMLScriptElement")}} interface now accept {{domxref("TrustedScript")}} objects a value, while {{domxref("HTMLScriptElement.src", "src")}} accepts {{domxref("TrustedScriptURL")}} values. ([Firefox bug 1905706](https://bugzil.la/1905706)).
380-
- The {{domxref("Window.setInterval()")}} and {{domxref("Window.setTimeout()")}} methods can be called with a {{domxref("TrustedScript")}}. ([Firefox bug 1931290](https://bugzil.la/1931290)).
381-
- The global [`trustedTypes`](/en-US/docs/Web/API/Window/trustedTypes) property is available for accessing the Trusted Types API.
382-
- The properties {{domxref("Element.innerHTML")}} and {{domxref("ShadowRoot.innerHTML")}} can be called with [trusted types](/en-US/docs/Web/API/Trusted_Types_API).
373+
- Addition of new interfaces {{domxref("TrustedTypePolicyFactory")}}, {{domxref("TrustedTypePolicy")}}, {{domxref("TrustedHTML")}}, {{domxref("TrustedScript")}}, {{domxref("TrustedScriptURL")}}, and the `trustedTypes` property on {{domxref("Window/trustedTypes", "Window")}} and {{domxref("WorkerGlobalScope/trustedTypes", "WorkerGlobalScope")}}
374+
- Updates to [injection sink](/en-US/docs/Web/API/Trusted_Types_API#concepts_and_usage) APIs, such as {{domxref("Element.innerHTML")}} and {{domxref("Document.write()", "document.write()")}}, to allow the `TrustedHTML`, `TrustedScript`, `TrustedScriptURL` to be passed as well as strings.
375+
- Support for the [`require-trusted-types-for`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for) directive of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
376+
This can be used to enforce that trusted types used instead of strings (or use a default policy).
377+
- Support for the [`trusted-types`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types) directive of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
378+
This can be used to restrict the allowed names of trusted type policies defined in the page.
383379

384380
| Release channel | Version added | Enabled by default? |
385381
| ----------------- | ------------- | ------------------- |
386-
| Nightly | 133 | No |
387-
| Developer Edition | 133 | No |
388-
| Beta | 133 | No |
382+
| Nightly | 145 | Yes |
383+
| Developer Edition | 145 | Yes |
384+
| Beta | 145 | Yes |
389385
| Release | 133 | No |
390386

391387
- `dom.security.trusted_types.enabled`

files/en-us/mozilla/firefox/releases/145/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,15 @@ You can find more such features on the [Experimental features](/en-US/docs/Mozil
109109
Nightly builds now support [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) by default, which allows to tether elements together.
110110
The anchor-positioned elements can then have their size and position set relative to the size and location of the anchor elements to which they are bound.
111111
([Firefox bug 1988224](https://bugzil.la/1988224)).
112+
113+
- **Trusted Types API** for scripts (Early Beta): `dom.security.trusted_types.enabled`
114+
115+
The [Trusted Types API](/en-US/docs/Web/API/Trusted_Types_API) is now fully implemented. ([Firefox bug 1976656](https://bugzil.la/1976656)).
116+
117+
The changes include:
118+
- Addition of new interfaces {{domxref("TrustedTypePolicyFactory")}}, {{domxref("TrustedTypePolicy")}}, {{domxref("TrustedHTML")}}, {{domxref("TrustedScript")}}, {{domxref("TrustedScriptURL")}}, and the `trustedTypes` property on {{domxref("Window/trustedTypes", "Window")}} and {{domxref("WorkerGlobalScope/trustedTypes", "WorkerGlobalScope")}}
119+
- Updates to [injection sink](/en-US/docs/Web/API/Trusted_Types_API#concepts_and_usage) APIs, such as {{domxref("Element.innerHTML")}} and {{domxref("Document.write()", "document.write()")}}, to allow the `TrustedHTML`, `TrustedScript`, `TrustedScriptURL` to be passed as well as strings.
120+
- Support for the [`require-trusted-types-for`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for) directive of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
121+
This can be used to enforce that trusted types used instead of strings (or use a default policy).
122+
- Support for the [`trusted-types`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types) directive of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
123+
This can be used to restrict the allowed names of trusted type policies defined in the page.

files/en-us/web/api/trusted_types_api/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,44 @@ Either way, the injection sink gets sanitized data, and because we could enforce
201201
- {{domxref("TrustedTypePolicyFactory")}}
202202
- : Creates policies and verifies that Trusted Type object instances were created via one of the policies.
203203

204+
### Extensions to other interfaces
205+
206+
The following sections list injection sinks that are expected to accept trusted types as well as strings.
207+
208+
#### TrustedHTML
209+
210+
- {{domxref("Document.parseHTMLUnsafe_static()")}}
211+
- {{domxref("Document.write()")}}
212+
- {{domxref("DOMParser.parseFromString()")}}
213+
- {{domxref("Element.innerHTML")}}
214+
- {{domxref("Element.insertAdjacentHTML")}}
215+
- {{domxref("Element.outerHTML")}}
216+
- {{domxref("Element.setHTMLUnsafe()")}}
217+
- {{domxref("HTMLIFrameElement.srcdoc")}}
218+
- {{domxref("Range.createContextualFragment()")}}
219+
- {{domxref("ShadowRoot.innerHTML")}}
220+
- {{domxref("ShadowRoot.setHTMLUnsafe()")}}
221+
222+
#### TrustedScript
223+
224+
- {{domxref("HTMLScriptElement.innerText")}}
225+
- {{domxref("HTMLScriptElement.textContent")}}
226+
- {{domxref("HTMLScriptElement.text")}}
227+
- {{domxref("window.setTimeout()")}}
228+
- {{domxref("window.setInterval()")}}
229+
230+
#### TrustedScriptURL
231+
232+
- {{domxref("HTMLScriptElement.src")}}
233+
- {{domxref("SvgAnimatedString.baseVal")}}
234+
235+
## Extensions to HTTP
236+
237+
- {{CSP("require-trusted-types-for")}}
238+
- : Enforces that [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) are passed to DOM XSS [injection sinks](/en-US/docs/Web/API/Trusted_Types_API#concepts_and_usage).
239+
- {{CSP("trusted-types")}}
240+
- : Used to specify an allowlist of [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) policy names.
241+
204242
## Examples
205243

206244
In the below example we create a policy that will create {{domxref("TrustedHTML")}} objects using {{domxref("TrustedTypePolicyFactory.createPolicy()")}}. We can then use {{domxref("TrustedTypePolicy.createHTML()")}} to create a sanitized HTML string to be inserted into the document.

0 commit comments

Comments
 (0)