Trusted Types

A browser security feature that makes dangerous DOM sinks such as innerHTML reject plain strings and accept only values produced by a policy you define.

In more detail

Enable it with the CSP directive require-trusted-types-for 'script'. You create policies with trustedTypes.createPolicy, whose functions sanitize input and return TrustedHTML; assigning a raw string then throws a TypeError, so every risky path is forced through reviewed code.

Related terms

Taught in

References