Skip to content
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

XSS (<script>, <style>) #168

Closed
ghost opened this issue May 3, 2014 · 3 comments
Closed

XSS (<script>, <style>) #168

ghost opened this issue May 3, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented May 3, 2014

html tags are not striped (or better will be to htmlspecialchars() them)


Test string:

<script type="text/javascript">alert('XSS');</script>
<style type="text/css">body { background: red; }</style>

Result: http://sourcebox.io/27978c3083f1bf93be8f9325d3a2a36b/markdown


Is there any option to enable safe html output? Or am I doing something wrong?


Github generates this html:

<p>body { background: red; }</p>

You can test that by executing this script in your browser console:

jQuery.post('/preview?text='+ encodeURIComponent('<script type="text/javascript">alert("XSS");</script><style type="text/css">body { background: red; }</style>'), function(html){ alert(html); });

Bitbucket.org generates this html:

<p>&lt;script type="text/javascript"&gt;alert('XSS');&lt;/script&gt;
&lt;style type="text/css"&gt;body { background: red; }&lt;/style&gt;</p>
@hkdobrev
Copy link
Contributor

hkdobrev commented May 3, 2014

A Markdown parser should accept HTML including scripts.

It is your responsibility to decide whether and how you would sanitize your input.

@ghost
Copy link
Author

ghost commented May 3, 2014

@hkdobrev ok thanks

@ghost ghost closed this as completed May 3, 2014
@clphillips
Copy link

@moldcraft see #161.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants