Firefox 148 is the first browser to ship the standardized Sanitizer API, which provides built-in XSS protection by sanitizing untrusted HTML before DOM insertion. The new `setHTML()` method replaces the error-prone `innerHTML` assignment, stripping dangerous elements and attributes by default. Developers can customize the sanitization configuration for stricter or more permissive rules, and can combine `setHTML()` with Trusted Types for centralized control over HTML injection. This approach requires minimal code changes and no dedicated security team, making XSS prevention accessible to a broader range of developers.

3m read timeFrom hacks.mozilla.org
Post cover image
Table of contents
About Tom SchusterAbout Frederik BraunAbout Christoph Kerschbaumer
4 Comments

Sort: