Skip to content

Commit 1578ce4

Browse files
committed
Add more items to trusted types sinks
1 parent 16cf6c0 commit 1578ce4

File tree

3 files changed

+46
-41
lines changed

3 files changed

+46
-41
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,10 @@ The API has been implemented and is enabled in early beta releases ([Firefox bug
412412

413413
This includes (non-exhaustively):
414414

415-
- 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")}}
416-
- 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.
417-
- 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.
418-
This can be used to enforce that trusted types used instead of strings (or use a default policy).
419-
- 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.
420-
This can be used to restrict the allowed names of trusted type policies defined in the page.
415+
- 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")}}.
416+
- Updates to [injection sink interfaces](/en-US/docs/Web/API/Trusted_Types_API#injection_sink_interfaces), such as {{domxref("Element.innerHTML")}} and {{domxref("Document.write()", "document.write()")}}, to allow the `TrustedHTML`, `TrustedScript`, `TrustedScriptURL` to be passed as well as strings.
417+
- Support for the [`require-trusted-types-for`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for) and [`trusted-types`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types) directives, and the [`'trusted-types-eval'`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#trusted-types-eval) keyword, of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
418+
These can be used to enforce trusted types instead of strings, name the specific policies that are allowed, and to enable [`eval()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and similar functions to be used when [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) are supported and enforced.
421419

422420
| Release channel | Version added | Enabled by default? |
423421
| ----------------- | ------------- | ------------------- |

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,12 @@ You can find more such features on the [Experimental features](/en-US/docs/Mozil
122122
The CSS `text-decoration-trim` property is supported but currently disabled by default.
123123
It allows you to specify {{cssxref("text-decoration")}} start and end offsets to shorten, lengthen, or shift the position of text decorations with respect to the text ([Firefox bug 1979915](https://bugzil.la/1979915)).
124124

125-
- **Trusted Types API** for scripts (Early Beta): `dom.security.trusted_types.enabled`
125+
- **Trusted Types API** for scripts (Nightly/Early Beta): `dom.security.trusted_types.enabled`
126126

127127
The [Trusted Types API](/en-US/docs/Web/API/Trusted_Types_API) is now fully implemented. ([Firefox bug 1976656](https://bugzil.la/1976656)).
128128

129129
The changes include:
130130
- 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")}}
131-
- 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.
132-
- 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.
133-
This can be used to enforce that trusted types used instead of strings (or use a default policy).
134-
- 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.
135-
This can be used to restrict the allowed names of trusted type policies defined in the page.
131+
- Updates to [injection sink interfaces](/en-US/docs/Web/API/Trusted_Types_API##injection_sink_interfaces) 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.
132+
- Support for the [`require-trusted-types-for`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for) and [`trusted-types`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types) directives, and the [`'trusted-types-eval'`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#trusted-types-eval) keyword, of the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
133+
These can be used to enforce trusted types instead of strings, name the specific policies that are allowed, and to enable [`eval()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and similar functions to be used when [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) are supported and enforced.

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

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The **Trusted Types API** gives web developers a way to ensure that input has be
1212

1313
## Concepts and usage
1414

15-
Client-side, or DOM-based, XSS attacks happen when data crafted by an attacker is passed to a browser API that executes that data as code. These APIs are known as _injection sinks_.
15+
Client-side, or DOM-based, XSS attacks happen when data crafted by an attacker is passed to a browser API that executes that data as code. These APIs are known as [_injection sinks_](#injection_sink_interfaces).
1616

1717
The Trusted Types API distinguishes three sorts of injection sinks:
1818

@@ -203,10 +203,33 @@ Either way, the injection sink gets sanitized data, and because we could enforce
203203

204204
### Extensions to other interfaces
205205

206-
The following sections list injection sinks that are expected to accept trusted types as well as strings.
206+
- {{domxref("Window.trustedTypes")}}
207+
- : Returns the {{domxref("TrustedTypePolicyFactory")}} object associated with the global object in the main thread.
208+
This is the entry point for using the API in the Window thread.
209+
- {{domxref("WorkerGlobalScope.trustedTypes")}}.
210+
- : Returns the {{domxref("TrustedTypePolicyFactory")}} object associated with the global object in a worker.
207211

208-
#### TrustedHTML
212+
### Extensions to HTTP
209213

214+
#### `Content-Security-Policy` directives
215+
216+
- {{CSP("require-trusted-types-for")}}
217+
- : 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).
218+
- {{CSP("trusted-types")}}
219+
- : Used to specify an allowlist of [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) policy names.
220+
221+
#### `Content-Security-Policy` keywords
222+
223+
- [`trusted-types-eval`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#trusted-types-eval)
224+
- : Allows [`eval()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and similar functions to be used but only when [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) are supported and enforced.
225+
226+
## Injection sink interfaces
227+
228+
This section provides a (potentially) non-exhaustive list of injection sink interfaces.
229+
230+
##### TrustedHTML
231+
232+
- {{domxref("Document.execCommand()")}} with a `commandName` of [`"insertHTML"`](/en-US/docs/Web/API/Document/execCommand#inserthtml)
210233
- {{domxref("Document.parseHTMLUnsafe_static()")}}
211234
- {{domxref("Document.write()")}}
212235
- {{domxref("Document.writeln()")}}
@@ -220,40 +243,26 @@ The following sections list injection sinks that are expected to accept trusted
220243
- {{domxref("ShadowRoot.innerHTML")}}
221244
- {{domxref("ShadowRoot.setHTMLUnsafe()")}}
222245

223-
#### TrustedScript
246+
##### TrustedScript
224247

248+
- [`eval()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)
249+
- [`Element.setAttribute()`](/en-US/docs/Web/API/Element/setAttribute#value) (`value` argument)
250+
- [`Element.setAttributeNS()`](/en-US/docs/Web/API/Element/setAttributeNS#value) (`value` argument)
251+
- [`Function()` constructor](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Function)
225252
- {{domxref("HTMLScriptElement.innerText")}}
226253
- {{domxref("HTMLScriptElement.textContent")}}
227254
- {{domxref("HTMLScriptElement.text")}}
228-
- {{domxref("window.setTimeout()")}}
229-
- {{domxref("window.setInterval()")}}
255+
- [`window.setTimeout()`](/en-US/docs/Web/API/Window/setTimeout#code) and [`WorkerGlobalScope.setTimeout()`](/en-US/docs/Web/API/WorkerGlobalScope/setTimeout#code) (`code` argument)
256+
- [`window.setInterval()`](/en-US/docs/Web/API/Window/setInterval#code) and [`WorkerGlobalScope.setInterval()`](/en-US/docs/Web/API/WorkerGlobalScope/setInterval#code) (`code` argument)
230257

231-
#### TrustedScriptURL
258+
##### TrustedScriptURL
232259

233260
- {{domxref("HTMLScriptElement.src")}}
261+
- {{domxref("ServiceWorkerContainer.register()")}}
234262
- {{domxref("SvgAnimatedString.baseVal")}}
235-
236-
<!--
237-
238-
These still require links, and possibly docs
239-
- [`ServiceWorkerContainer.register()`](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/register)
240-
- [`WorkerGlobalScope.importScripts`](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/importScripts)
241-
- [`Window.trustedTypes`](https://developer.mozilla.org/docs/Web/API/Window/trustedTypes)
242-
-->
243-
244-
## Extensions to HTTP
245-
246-
{{httpheader("Content-Security-Policy")}} directives:
247-
248-
- {{CSP("require-trusted-types-for")}}
249-
- : 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).
250-
- {{CSP("trusted-types")}}
251-
- : Used to specify an allowlist of [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) policy names.
252-
253-
{{httpheader("Content-Security-Policy")}} keywords:
254-
255-
- [`'trusted-types-eval'`](/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#trusted-types-eval)
256-
- : Allows [`eval()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and similar functions to be used but only when [Trusted Types](/en-US/docs/Web/API/Trusted_Types_API) are supported and enabled.
263+
- {{domxref("WorkerGlobalScope.importScripts()")}}
264+
- `url` argument to [`Worker()` constructor](/en-US/docs/Web/API/Worker/Worker#url)
265+
- `url` argument to [`SharedWorker()` constructor](/en-US/docs/Web/API/SharedWorker/SharedWorker#url)
257266

258267
## Examples
259268

0 commit comments

Comments
 (0)