sympy/sympy-live

Running arbitrary code

donno2048 opened this issue · 8 comments

I have found a way to run any JavaScript code on the browser from SymPy Live,
It can be simply done using this input:

"\unicode{<img src=x onerror=\"%s\"/>}" % "alert(0)"

(Where instead of alerting you could use any JavaScript code)
To make it "prettier" and not to show the 𐀀 character you can simply use:

"\phantom{\unicode{</mtext></mphantom></mrow></math><img src=x onerror=\"%s\"/><math><mrow><mphantom><mtext>}}" % "alert(0)"

I don't know if this is a security concern because the code would only run on your computer, but we should escape the output regardless.

Do you know how to escape the output? We also need to make sure that the MathJax rendering still works.

I think the first thing to check is whether it's a problem with SymPy-Live or a global problem with MathJax (which I should probably have done earlier), if it's specific to SymPy-Live the only solution I see is a noscript block or escaping < and > in a unicode element or something like that

I guess what you're saying is that someone can post a URL for the sympy website that causes malicious code to run on the someone's machine if they click the link.

That does seem like a valid concern

I guess what you're saying is that someone can post a URL for the sympy website that causes malicious code to run on the someone's machine if they click the link.

Yes, exactly

To quote Wikipedia regarding reflected XSS:

"The bait is an innocent-looking URL, pointing to a trusted site but containing the XSS vector. If the trusted site is vulnerable to the vector, clicking the link can cause the victim's browser to execute the injected script."

Merging #193 should fix it

This is stale and will be resolved when the deployment succeeds.