From my understanding, a lot of mXSS is caused by additional parsing:
With Trusted Types, additional parsing is basically impossible to avoid, because
- user calls
innerHTML
- browser calls
createHTML
createHTML uses a sanitizer (parses, sanitizes and serializes to a string)
- return value of
createHTML is being parsed again by innerHTML
I think we could make mXSS easier to avoid if the createHTML function gets optional arguments about the parsing context (an element? or an element name?).
CCing some folks since I am not sure if they watch the repo 🙂 @annevk, @koto