-
Notifications
You must be signed in to change notification settings - Fork 47
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
Prevent XSS in Latex and SVG Elements #47
Prevent XSS in Latex and SVG Elements #47
Conversation
roman-mibex-2
commented
Aug 2, 2023
- The svg handler added the notebook content directly to the .innerHTML, allowing it to run JavaScript by using HTML tags instead of HTML. Fixed by running the sanitizer over the SVG.
- The latex handler added its content directly to the .innerHTML. This allowed to inject any JavaScript/HTML instead of Latex. Fixed by using .innerText, to render the content.
To discuss:
Also, the Latex text is rendered differently. Example |
Thanks for this, @roman-mibex-2. Some notes below:
Is there a method we could provide 3rd-party developers that would allow them to override this issue. Or are the current options sufficient, and only require the 3rd-party developers to make minor adjustments?
For my own notes: This refers to https://github.com/jsvine/notebookjs/pull/48/files
Do you think there's a way to get the "after" version to render as it previously did? Or is this unavoidable if we're trying to prevent XSS? |
We used the mentioned 3rd party app so far. I couldn't make it work while also preventing any XSS. The main reason is that this 3rd party app relied on the XSS 'friendliness'. It was a pre-processor for the ipynb-JSON and replaced String literals with HTML tags to then have it rendered by notebookjs. That is a very fragile way to do it and I failed to make it safe.
There are multiple options here:
|
6529642
to
8edcc5e
Compare
- The svg handler added the notebook content directly to the .innerHTML, allowing it to run JavaScript by using HTML tags instead of HTML. Fixed by running the sanitizer over the SVG. - The latex handler added its content directly to the .innerHTML. This allowed to inject any JavaScript/HTML instead of Latex. Fixed by using .innerText, to render the content.
New lines are not rendered by default in previous version, MathJax etc. Therefore, keep that behavior consistent and don't render new lines in Latex output
8edcc5e
to
57651a6
Compare
Ping. In case I won't react next week, I am on vacation. |
Thank you; ping received. I've been a bit busy, but still intend to review this and respond. Thanks for your patience. |
Thank you again for this, @roman-mibex-2, and my apologies for the delay in following up. I'm going to merge this, but tweak the latex solution a bit — default will be |
Actually, now that I see your proposed fix in #48, let's go with that as the Latex solution. (Still merging the SVG fix in this PR.) |