This is a migrated thread and some comments may be shown as answers.

XSS and SQL Injection

5 Answers 742 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 2
Iron
Jack asked on 22 Sep 2011, 04:45 PM
I did not yet dwelve into the code.
Any provision in the framework to prevent XSS and SQL Injection?
Otherwise, what are recommended best practices?

5 Answers, 1 is accepted

Sort by
0
Richard Cuti
Top achievements
Rank 2
answered on 28 Feb 2012, 08:18 PM
A very good question. I can't seem to find an answer. We are evaluating Kendo UI for our next project and we need to be able to answer this question.

Thanks in advance...
0
Atanas Korchev
Telerik team
answered on 29 Feb 2012, 08:41 AM
Hello,

What kind of provisions to prevent XSS and SQL Injection are you looking for? Have in mind that Kendo is a client-side framework and XSS and SQL injection are best taken care of server side. 

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
EC
Top achievements
Rank 1
answered on 30 Oct 2013, 09:43 AM
Hello Atanas,

From the client-side perspective, data coming from any server cannot be trusted, even when it's one of your own servers (which may be hacked).
While it is true that you need XSS protection on your server, it's certainly not a luxury to have additional protection on the client-side.

The kendo.template() function for example can be extended to filter out any unwanted <script> tags. The following code would do it:
var kendoTemplate = kendo.template;
kendo.template = function () {
    var templateFunction = kendoTemplate.apply(kendoTemplate, arguments);
    return function () {
        var htmlWithoutScripts = $.parseHTML(templateFunction.apply(templateFunction, arguments));
        return $("<div></div>").html(htmlWithoutScripts).html();
    }
};
The jQuery.parseHTML() function will strip any <script> tags...
I'm not sure what the impact is for performance when there are too many repeated template calls on the same screen, but for normal use the overhead should be minimal.
Could this kind of XSS protection be added to Kendo UI by default? Or at least be available as an option?

Best Regards,
Wannes Simons.
0
Atanas Korchev
Telerik team
answered on 30 Oct 2013, 11:16 AM
Hello,

We may indeed add support for such script element stripping. Do you mind logging a new feature request in our feedback portal?

 Unfortunately we cannot enable such capability by default because it would be a breaking change and would affect performance. Perhaps we can make it optional or introduce a new method.

 I should also add that a compromised server could render arbitrary JS which no third party JS library could prevent from executing. For example including malicious JavaScript code.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
EC
Top achievements
Rank 1
answered on 30 Oct 2013, 11:57 AM
Thanks Atanas,

You are right, a fully compromised server would be able to run any JavaScript :-) It's for those cases when only the database get attacked or some external content gets mixed with the data.

I've added the suggestion on the feedback forum: http://feedback.kendoui.com/forums/127393-kendo-ui-feedback/suggestions/4838380-add-cross-site-scripting-xss-prevention

Best Regards,
Wannes Simons.
Tags
General Discussions
Asked by
Jack
Top achievements
Rank 2
Iron
Answers by
Richard Cuti
Top achievements
Rank 2
Atanas Korchev
Telerik team
EC
Top achievements
Rank 1
Share this question
or