Tuesday, July 16, 2019

Secure ASP.NET MVC website

Below are some of the Security feature to secure ASP.NET MVC web application

1. Cross Site Scripting (XSS)
2. Cross site request forgery (CSRF)
3. Authentication
          Windows
           Forms


1. Cross Site Scripting (XSS)

  • XSS is a attack, where malicious user tries to inject scripts in input fields like a Textbox or TextArea like Hack
  •  To prevent this type of attack .Net framework has inbuilt functionality of ValidateRequest
  • But some time we have a requirement to allow script into the TextBox or TextArea to format input text, at that time we have to allow Scripts in TextBox or TextArea
  • In this situation we have a another option of Encode textbox input using Server.HtmlEncode(textbox) in aspx engine
  • for Razor View Engine, it will automatically handle XSS scripts
2. Cross site request forgery (CSRF)
  • CSRF is a attach, where malicious user tries to POST malicious data into URL Post request
  • to prevent this attach, there is inbuilt function of Html.AntiForgeryToken() which we need to call inside form

3. Authentication
  •  Windows Authentication - we need to config in Web.config authentication mode=Windows
  • Forms Authentication - we have to config in Web.config authentication mode=Forms and add custom code to Authenticate users
Once users are Authenticate, we will use Authorize Attribute on the Controller to verify user and Authorize them for the access of particular page

No comments:

Post a Comment