Mozilla Hacks
Read post

Goodbye innerHTML, Hello setHTML: Stronger XSS Protection in Firefox 148

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.

    #security#firefox#web-security
Feb 24•3m read time•From hacks.mozilla.org
Post cover image
Table of contents
About Tom SchusterAbout Frederik BraunAbout Christoph Kerschbaumer
196.1K Impressions4 Comments
Mozilla Hacks's image
Mozilla Hacks

Hacks is a platform for sharing and discovering life hacks, productivity tips, and personal developm...

19 Followers

•

88 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard