How do you avoid XSS vulnerabilities in ASP.Net (MVC)?
I recently noticed that I had a big hole in my application because I had done something like:
I recently noticed that I had a big hole in my application because I had done something like:
I just ran across a question with an answer suggesting the AntiXss library to avoid cross site scripting. Sounded interesting, reading the msdn blog, it appears to just provide an HtmlEncode() method. But I already use HttpUtility.HtmlEncode().
I have a website that allows to enter HTML through a TinyMCE rich editor control. It’s purpose is to allow users to format text using HTML.
When you can simply encode the data using HttpUtility.HtmlEncode, why should we use AntiXss.HtmlEncode?
Is there a utility/function in C# to sanitize the source code of tinyMCE rich text. I would like to remove dangerous tags but like to whitelist safe html tags.
Inspired by this CodingHorror article, “Protecting Your Cookies: HttpOnly“
I’ve tried looking at the Microsoft site and Googling this but nobody seems to have an answer aside from the < and the >. There’s more to it than that though. I’ve noticed that the HTML entity starter of &# is invalid. Is there anything else? Does anyone have a complete list?
In asp.net is the PagesSection.ValidateRequest method enough to prevent all XSS attacks or is there something more that needs to be done?
I have an editor that lets users add HTML that is stored in the database and rendered on a web page. Since this is untrusted input, I plan to use Microsoft.Security.Application.AntiXsSS.GetSafeHtmlFragment to sanitize the HTML.