-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Link to definition of default "XSS-safe" elements and attributes #41630
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
base: main
Are you sure you want to change the base?
Conversation
"XSS-safe" is not well-defined within MDN so let's link to the spec.
|
Preview URLs External URLs (1)URL:
|
|
I wish we had a better explanation for this that we could link to. Maybe this something WICG/sanitizer-api#287 should aspire to define. |
|
We should explain this but I don't think this link is very helpful. Apart from being quite hard to read, I'm not sure what it means. For instance when it says: {
"name": "abbr",
"namespace": "http://www.w3.org/1999/xhtml",
"attributes": []
}...does that mean that by default no attributes are allowed on It would be great to have a page under https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API that describes the default configuration. I also don't understand the difference between the "built-in safe default configuration" and the "built-in safe baseline configuration" and would prefer not to have to pick through the spec to try to work it out. @hamishwillee , what do you think? |
I agree with you - generally we don't link to spec and I don't think this is all that useful a link. The TLDR IMO is that 99% of people don't need to know the list - this should be used as a drop in replacement for innerHTML. If you're injecting any of those untrusted things you should be talking a long hard look at yourself :-) That said, I guess it might help people who are wondering why something in the input disappeared. Since the text is huge and may change we could do this:
As I understand it, the "built-in safe default configuration" is the very restrictive configuration you get by default. This excludes anything that can cause an XSS attack AND some other bits and bobs that can in theory lead to other less worrying attacks such as clickjacking. I believe that removeUnsafe() is the only thing that uses the more permissive version. That is not documented, and possibly should be.
It means that |
Description
Link to the specification to define what "XSS-safe" means.
"XSS-safe" is not well-defined within MDN so let's link to the spec.
Motivation
The current description of the default sanitizer's behavior is ultimately not meaningful.
Additional details
I don't know if "XSS-safe" is a well-defined term within the spec, but if it is then the definition should be linked in MDN (or translated to it)
Related issues and pull requests