-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mXSS: should createHTML
get information about the context?
#569
Comments
Wasn't this effectively solved by this issue in the Sanitiser spec? |
This isn't directly about the sanitizer API so no that issue is separate. This is about trusted types as used today with the likes of DOMPurify. One question I have is does this context actually help. Like does DOMPurify have to guess currently where with this new param it could behave better with an existing option? Also worth being aware this only applies in the case of the default policy. |
This is about a lower-case sanitizer, not the Sanitizer spec. I think this is required because parsing HTML fragments is not a function that accepts a string. Parsing behavior is very different depending on the context. All of this can be sidelined if the allow-list in the sanitizer is very strict, of course. |
Well, DOMPurify hacks around it here and there.
Not sure I understand. Can you give an example? |
The general usage of trusted types policies is that the author calls createHTML and then passes the resultant TrustedHTML to the sink. The browser only gets involved in that process when there's a default policy in use and you assign a string to a sink. |
So what would the design look like here? I think that could be interesting as defense-in-depth, but I'm not sure it's worth the complexity. Probably worth keeping this open though to see if this is something that people run into in the wild. What's not worth it today might be tomorrow. |
From my understanding, a lot of mXSS is caused by additional parsing:
With Trusted Types, additional parsing is basically impossible to avoid, because
innerHTML
createHTML
createHTML
uses a sanitizer (parses, sanitizes and serializes to a string)createHTML
is being parsed again byinnerHTML
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
The text was updated successfully, but these errors were encountered: