The Pos Ronda notice board: a notice through the real trustedTypes.createPolicy. See what createHTML returns, and whether a passthrough policy still guards…
Why it matters
DOM XSS happens when untrusted data reaches a sink like innerHTML. Trusted Types turns those hundreds of points into one review: a sink only takes a value from a policy. But it forces a policy to exist, not that the policy is right, needs a CSP to be active, and must be feature-detected. Misreading this makes people think XSS is solved when it is not.
The key idea
Trusted Types forces sinks through a policy; it does not sanitise for you
Common mistakes
A policy is set but XSS still gets through A policy whose createHTML returns its input gives a TrustedHTML that still carries the attack. The policy must really review: escape, or sanitise with a tested library (e.g. DOMPurify) inside createHTML.
One policy named 'default' becomes a way around everything A 'default' policy is used automatically by every sink that gets a string, so if it is loose, the whole app is loose. Safer: a few named policies, limited by the CSP trusted-types policy-name.
Seems not to work in older Safari / Firefox Trusted Types is not in every browser, so feature-detect window.trustedTypes and keep a safe path without it. It is a layer on top of sanitising and CSP, not a replacement for them.
Try it in this playground
Send a notice through a reviewing policycreateHTML escapes the HTML into a TrustedHTML whose contents are text.
Use textContent for text Not an HTML sink: tags show as letters, with no policy.
Spot the passthrough policy The result is a TrustedHTML, but its contents are unchanged: still markup.
Try raw innerHTML on this page This page sets no require-trusted-types-for, so nothing throws.