I read a lot of posts about SO regarding XSS and how to deal. As a rule, consensus is a “white list” of the “black list” and avoids the use of regular expressions (there are too many options to solve).
I am working on an ASP.Net MVC3 application. I need to be able to display HTML from a user record (e.g. <strong>, <ul>, <li>, etc.), but I don't need the risks of XSS.
I am using the AntiXSS package through Nuget. In my model I have
[AllowHtml] public string UserDetails{ get; set; }
In my opinion, I have TinyMCE connected to the text area.
In my controller, I get the message from the view and sanitize it:
using Microsoft.Security.Application; ... string SanitizedDetails = Sanitizer.GetSafeHtmlFragment(model.UserDetails);
My question is: did I do everything right? Am I protected from most XSS issues, or am I barking the wrong tree?
source share