-
-
Notifications
You must be signed in to change notification settings - Fork 723
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
Why are annotation and semantics MathML tags forbidden? #673
Comments
It seems the reason is partly explained in the code below. https://github.com/cure53/DOMPurify/blob/main/src/tags.js#L197-L260 // List of SVG elements that are disallowed by default.
// We still need to know them so that we can do namespace
// checks properly in case one wants to add them to
// allow-list.
...
// Similarly to SVG, we want to know all MathML elements,
// even those that we disallow by default.
export const mathMlDisallowed = freeze([
'maction',
'maligngroup',
'malignmark',
'mlongdiv',
'mscarries',
'mscarry',
'msgroup',
'mstack',
'msline',
'msrow',
'semantics',
'annotation',
'annotation-xml',
'mprescripts',
'none',
]); |
They cause mXSS and hence need to be handled with great care. See here https://github.com/cure53/DOMPurify/blob/main/test/fixtures/expect.js#L1094 You can of course allow those tags via config if this is not a risk for you, but by default, we have to prohibit them, sadly. |
Thank you for the explanation! Definitely makes sense not to allow them in general then. This may not be the right forum, but I'd like to know more about the vector, in order to protect my site but allow the form generated by KaTeX.
|
That is a good question and we'd probably have to try it out and see what browsers do in that regard.
My guess is that you are right here, but I frankly don't know for sure :) |
Background & Context
KaTeX generates MathML with
<annotation>
and<semantics>
tags, which include the original LaTeX source code.Is there a security risk I'm missing in
semantics
andannotation
?Desired behavior
Input
Example generated by KaTeX on input
x
:Given output
Expected output
Same as input.
The text was updated successfully, but these errors were encountered: