-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 vulnerability #70
Comments
Wouldn't it be better to be more specific with the regular expression? For this particular one I'm using: text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(?:(?:['"])?((?:(?:http|https):\/\/)?(?:[\w\-_]+(?:(?:\.[\w\-_]+)+))(?:[\w\-\.,@?^=%&:\/~\+\!#]*[\w\-\@?^=%&\/~\+#]))['"]?)\))/g, writeAnchorTag); This doesn't allow spaces at the end of the url or anything between the quote and ending parenthesis. [parses](http://www.example.com)
[does not parse](http://www.example.com" ) UPDATE: This one allows for inline url with title - the one I'm currently using: text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(?:(?:['"])?((?:(?:http|https):\/\/)?(?:[\w\-_]+(?:(?:\.[\w\-_]+)+))(?:[\w\-\.,@?^=%&:\/~\+\!#]*[\w\-\@?^=%&\/~\+#]))['"]?)()()(?:\s)?(?:['"](.*)(?:['"]))?\))/g, writeAnchorTag); example: [parses](http://www.example.com "Title")
[does not parse](http://www.example.com "title" ) // No spaces or characters after last parenthesis
[does not parse](www.example.com "title") // More than one space between url and title When adding inline title it must have two quotes. |
@tgienger @jorilallo Maybe some simple xss prevention is a good idea. A couple of approaches come to mind:
However, I'm a bit averse to add this kind of protection into the core converters because:
Opinions and feedback are welcome. |
This is definitely not the responsibility of a converter to protect against XSS. I would defer to using a XSS filter on showdown output. See https://github.com/leizongmin/js-xss. That being said, I think we should add a note about XSS aspects. |
Best way to handle this would be to have a showdown-xss output type extension dealing with such matter. Anyone up to the task? I've added a reference in Contributing wiki page. Closing for now. |
Addresses showdownjs#70 at least within angular.
@pdeschen We just published showdown-xss-filter to npm using the library you suggested above. Seems to work great, hope that helps! |
@markgeraty nice! you should add unit test and bower support eventually, with a dep over xss (which is already available within bower) |
Created issues for those - feel free to create an issue for anything else you think we are missing! VisionistInc/showdown-xss-filter#1 |
@markgeraty Awesome! Kudos! |
For more information, please see the wiki page about Markdown's XSS Vulnerability and how to mitigate it |
It seems that link and image titles can be abused easily. Here's and example:
This is prevented on titles but not in urls. Fix is pretty easy:
The text was updated successfully, but these errors were encountered: