Web & application

Trusted Types

A browser API, enforced via CSP, that blocks strings from reaching DOM XSS sinks like innerHTML unless they pass through a vetted policy.

With Content-Security-Policy: require-trusted-types-for 'script', assigning a plain string to sinks such as innerHTML, outerHTML, eval, or a script element's src throws. Code must create a TrustedHTML, TrustedScript or TrustedScriptURL through a named policy, typically one that runs a sanitiser such as DOMPurify. The trusted-types directive limits which policy names may exist.

It turns DOM XSS from a review problem (find every sink in a large codebase) into a small audit (review the few policy functions). Google reports it effectively eliminated DOM XSS in applications that adopted it.

Rollout is usually report-only first because third-party libraries write to sinks. Support arrived in Chromium first, with other engines following later, so keep sanitisation and strict CSP as the baseline everywhere.

Learn it properly

Also used in

Related terms