Trusted Types — block DOM-based XSS at the browser
TL;DR
Trusted Types make the browser refuse raw strings in dangerous DOM sinks such as innerHTML, accepting only values made by a policy you wrote. You turn them on with one Content-Security-Policy directive, require-trusted-types-for.
Explain Simply
Imagine a building where every package must carry a stamp from the front desk before it goes upstairs. A package with no stamp is turned away, even if someone slipped it through the door.
Trusted Types is a security feature that helps prevent DOM-based cross-site scripting (DOM XSS). By default many DOM APIs, such as innerHTML and document.write, accept raw strings, and a string that holds script from an untrusted source can run. Once Trusted Types are enforced through CSP, those sinks accept only objects such as TrustedHTML, made by policies you authorise.
Chrome's Modern Web Guidance guide on Trusted Types (developer.chrome.com/docs/modern-web-guidance/guides/security/trusted-types) gives four steps: define a policy that sanitises or transforms strings, use it to create Trusted Type objects, use those objects when writing to sinks, and enforce Trusted Types with a Content Security Policy.
Content-Security-Policy: require-trusted-types-for 'script'
The guide advises rolling out with the Content-Security-Policy-Report-Only header first, which logs violations to your reporting endpoint without blocking any writes. See the Modern Web Guidance wiki page for the other guides CiteStat maps.
⚡Why It Matters
DOM XSS lets an attacker run script in your visitors' browsers through a page that writes untrusted text into the DOM. Trusted Types close that path by default. Search engines do not rank for it, but a hacked page loses visitors and trust, and browsers and Google flag compromised sites.
🔍How CiteStat Checks
CiteStat reads the Content-Security-Policy response header and looks for require-trusted-types-for. It is reported, not scored: it suits sites that write to DOM sinks, so absence is advice, not a fault.
CiteStat Score Impact
Reported, not scored: the rule never moves the headline score or a category card.
Fix Difficulty
Editor: Not relevant | Developer: Hard | AI Agent: Medium